From b73d75610640bbd78cadba5e7478fe53055a0a9e Mon Sep 17 00:00:00 2001 From: panw Date: Tue, 25 Nov 2025 16:35:35 +0800 Subject: [PATCH] =?UTF-8?q?refactor(hero):=20=E7=A7=BB=E9=99=A4=E6=80=92?= =?UTF-8?q?=E6=B0=94=E5=80=BC=E7=9B=B8=E5=85=B3=E5=B1=9E=E6=80=A7=E5=92=8C?= =?UTF-8?q?=E9=80=BB=E8=BE=91,=E4=BF=AE=E6=94=B9hp=E6=98=BE=E7=A4=BA?= =?UTF-8?q?=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 移除英雄属性组件中的怒气值(pow)属性及相关配置 删除英雄视图组件中怒气值显示和使用的逻辑 简化资源管理,移除不再使用的代码 --- assets/script/game/common/config/HeroAttrs.ts | 4 -- assets/script/game/hero/HeroAttrsComp.ts | 3 +- assets/script/game/hero/HeroViewComp.ts | 37 ++++++------------- 3 files changed, 13 insertions(+), 31 deletions(-) diff --git a/assets/script/game/common/config/HeroAttrs.ts b/assets/script/game/common/config/HeroAttrs.ts index c26b26e4..ba91b434 100644 --- a/assets/script/game/common/config/HeroAttrs.ts +++ b/assets/script/game/common/config/HeroAttrs.ts @@ -32,8 +32,6 @@ export enum Attrs { HP_REGEN = 3, // 生命回复 MP_REGEN = 4, // 魔法回复 HEAL_EFFECT = 5, // 治疗效果 - POW_MAX = 6, // 最大怒气值 - POW_REGEN = 7, // 怒气值回复 // ========== 攻击属性 (10-19) ========== AP = 10, // 攻击力 @@ -158,8 +156,6 @@ export const AttrsType: Record = { [Attrs.SHIELD_MAX]: BType.VALUE, // 最大护盾值 - 数值型 [Attrs.HP_REGEN]: BType.VALUE, // 生命回复 - 数值型 [Attrs.MP_REGEN]: BType.VALUE, // 魔法回复 - 数值型 - [Attrs.POW_MAX]: BType.VALUE, // 最大怒气值 - 数值型 - [Attrs.POW_REGEN]: BType.VALUE, // 怒气值回复 - 数值型 [Attrs.HEAL_EFFECT]: BType.RATIO, // 治疗效果 - 百分比型 // ========== 攻击属性(数值型) ========== diff --git a/assets/script/game/hero/HeroAttrsComp.ts b/assets/script/game/hero/HeroAttrsComp.ts index 8d7092db..e00272a8 100644 --- a/assets/script/game/hero/HeroAttrsComp.ts +++ b/assets/script/game/hero/HeroAttrsComp.ts @@ -31,7 +31,6 @@ export class HeroAttrsComp extends ecs.Comp { // ==================== 动态属性值 ==================== hp: number = 100; // 当前血量 mp: number = 100; // 当前魔法值 - pow: number = 0; // 当前怒气值 shield: number = 0; // 当前护盾 Attrs: any = []; // 最终属性数组(经过Buff计算后) NeAttrs: any = []; // 负面状态数组 @@ -150,6 +149,8 @@ export class HeroAttrsComp extends ecs.Comp { this.recalculateSingleAttr(attrIndex); } + + // ==================== 属性计算系统 ==================== /** * 重新计算单个属性 diff --git a/assets/script/game/hero/HeroViewComp.ts b/assets/script/game/hero/HeroViewComp.ts index f7ffd659..c2f260f5 100644 --- a/assets/script/game/hero/HeroViewComp.ts +++ b/assets/script/game/hero/HeroViewComp.ts @@ -31,8 +31,6 @@ export class HeroViewComp extends CCComp { status:String = "idle" scale: number = 1; // 显示方向 box_group:number = BoxSet.HERO; // 碰撞组 - usePower:boolean = false; - useMp:boolean = false; realDeadTime:number=10 deadCD:number=0 // 血条显示相关 @@ -89,10 +87,7 @@ export class HeroViewComp extends CCComp { // } /* 显示角色血*/ this.top_node.getChildByName("hp").active = true; - this.usePower=HeroInfo[this.model.hero_uuid].type==HType.warrior||HeroInfo[this.model.hero_uuid].type==HType.assassin; - this.useMp=HeroInfo[this.model.hero_uuid].type==HType.mage||HeroInfo[this.model.hero_uuid].type==HType.remote||HeroInfo[this.model.hero_uuid].type==HType.support; - this.top_node.getChildByName("pow").active = this.usePower; - this.top_node.getChildByName("mp").active = this.useMp; + this.top_node.getChildByName("mp").active = true; // 初始隐藏血条(被攻击后才显示) this.top_node.active = false; } @@ -140,9 +135,9 @@ export class HeroViewComp extends CCComp { this.processDamageQueue(); // 伤害数字显示队列 // ✅ 更新 UI 显示(数据由 HeroAttrSystem 更新) + // 移除了每帧调用的 hp_show,改为仅在需要时调用 this.hp_show(this.model.hp, this.model.Attrs[Attrs.HP_MAX]); - if(this.useMp) this.mp_show(this.model.mp, this.model.Attrs[Attrs.MP_MAX]); - if(this.usePower) this.pow_show(this.model.pow, this.model.Attrs[Attrs.POW_MAX]); + this.mp_show(this.model.mp, this.model.Attrs[Attrs.MP_MAX]); this.show_shield(this.model.shield, this.model.Attrs[Attrs.SHIELD_MAX]); } @@ -297,9 +292,10 @@ export class HeroViewComp extends CCComp { health(hp: number = 0, is_num:boolean=true) { // 生命值更新由 Model 层处理,这里只负责视图表现 this.heathed(); - if(this.model) { - this.hp_show(hp, this.model.Attrs[Attrs.HP_MAX]); - } + this.hp_tip(TooltipTypes.health, hp.toFixed(0)); + this.top_node.active=true + this.hp_show(this.model.hp, this.model.Attrs[Attrs.HP_MAX]); + } alive(){ @@ -390,19 +386,8 @@ export class HeroViewComp extends CCComp { } // 伤害计算和战斗逻辑已迁移到 HeroBattleSystem - /** 死亡触发器(预留,用于天赋/特殊效果) */ - do_dead_trigger(){ - if(!this.model || this.model.is_dead || this.model.fac === FacSet.MON) return; - // 预留:天赋触发、复活检查等 - } - - /** 受击触发器(预留,用于天赋/特殊效果) */ - do_atked_trigger(){ - if(!this.model || this.model.is_dead || this.model.fac === FacSet.MON) return; - // 预留:反击、护盾触发等 - } - + /** 调试日志(已禁用) */ to_console(value:any, value2:any=null, value3:any=null){ @@ -415,7 +400,7 @@ export class HeroViewComp extends CCComp { switch(skill.act){ case "max": this.as.max() - this.tooltip(TooltipTypes.skill, skill.name, skill_id) + this.tooltip(TooltipTypes.skill, skill.name) break case "atk": this.as.atk() @@ -458,9 +443,9 @@ export class HeroViewComp extends CCComp { this.hp_show(this.model.hp, this.model.Attrs[Attrs.HP_MAX]); this.in_atked(anm, this.model.fac==FacSet.HERO?1:-1); if (isCrit) { - this.hp_tip(TooltipTypes.crit, damage.toFixed(0), damage); + this.hp_tip(TooltipTypes.crit, damage.toFixed(0)); } else { - this.hp_tip(TooltipTypes.life, damage.toFixed(0), damage); + this.hp_tip(TooltipTypes.life, damage.toFixed(0)); } } reset() {