diff --git a/assets/script/game/hero/HeroAttrsComp.ts b/assets/script/game/hero/HeroAttrsComp.ts index 16745d05..3cf83e52 100644 --- a/assets/script/game/hero/HeroAttrsComp.ts +++ b/assets/script/game/hero/HeroAttrsComp.ts @@ -3,7 +3,6 @@ import { Attrs, AttrsType, BType, NeAttrs } from "../common/config/HeroAttrs"; import { BuffConf } from "../common/config/SkillSet"; import { HeroInfo, AttrSet } from "../common/config/heroSet"; import { HeroSkillsComp } from "./HeroSkills"; -import { HeroViewComp } from "./HeroViewComp"; interface talTrigger{ @@ -127,26 +126,32 @@ export class HeroAttrsComp extends ecs.Comp { if(!isValue){ addValue = value * this.Attrs[Attrs.HP_MAX] / 100; } - let heroView = this.ent.get(HeroViewComp); - if(heroView){ - heroView.health(addValue); - } + + // ✅ 数据层只负责数据修改,不调用视图层 + // let heroView = this.ent.get(HeroViewComp); + // if(heroView){ + // heroView.health(addValue); + // } + this.hp += addValue; this.hp = Math.max(0, Math.min(this.hp, this.Attrs[Attrs.HP_MAX])); - this.dirty_hp = true; // 标记血量需要更新 + this.dirty_hp = true; // ✅ 仅标记需要更新 } add_mp(value:number,isValue:boolean){ let addValue = value; if(!isValue){ addValue = value * this.Attrs[Attrs.MP_MAX] / 100; } - let heroView = this.ent.get(HeroViewComp); - if(heroView){ - heroView.mp_add(addValue); - } + + // ✅ 数据层只负责数据修改,不调用视图层 + // let heroView = this.ent.get(HeroViewComp); + // if(heroView){ + // heroView.mp_add(addValue); + // } + this.mp += addValue; this.mp = Math.max(0, Math.min(this.mp, this.Attrs[Attrs.MP_MAX])); - this.dirty_mp = true; // 标记魔法值需要更新 + this.dirty_mp = true; // ✅ 仅标记需要更新 } add_shield(value:number,isValue:boolean){ let addValue = value; diff --git a/assets/script/game/hero/HeroViewComp.ts b/assets/script/game/hero/HeroViewComp.ts index cf66f441..b6c3bbc2 100644 --- a/assets/script/game/hero/HeroViewComp.ts +++ b/assets/script/game/hero/HeroViewComp.ts @@ -81,7 +81,7 @@ export class HeroViewComp extends CCComp { collider.enabled = true; // 先禁 collider.group = this.box_group; // 设置为英雄组 } - + },0.1) // let anm = this.node.getChildByName("anm") // anm.setScale(anm.scale.x*0.8,anm.scale.y*0.8); @@ -312,17 +312,22 @@ export class HeroViewComp extends CCComp { } health(hp: number = 0) { - // 生命值更新由 Model 层处理,这里只负责视图表现 + // ✅ 仅显示特效和提示,不调用 hp_show() this.heathed(); this.hp_tip(TooltipTypes.health, hp.toFixed(0)); - this.top_node.active=true - this.hp_show(); + this.top_node.active = true; + + // ❌ 移除:UI更新由脏标签机制处理 + // this.hp_show(); } + mp_add(mp: number = 0) { - // 生命值更新由 Model 层处理,这里只负责视图表现 + // ✅ 仅显示提示,不调用 mp_show() this.hp_tip(TooltipTypes.addmp, mp.toFixed(0)); - this.top_node.active=true - this.mp_show(); + this.top_node.active = true; + + // ❌ 移除:UI更新由脏标签机制处理 + // this.mp_show(); } alive(){