fix(英雄属性): 修复MP更新时视图未同步的问题

修改HeroAttrsComp在更新MP值时调用HeroViewComp的mp_add方法同步视图
重命名HeroViewComp的mp方法为mp_add以更准确描述其功能
移除HeroViewComp中未使用的pow_show方法
This commit is contained in:
2025-11-26 10:14:06 +08:00
parent ab4d29d42b
commit df3ad88c3e
2 changed files with 6 additions and 8 deletions

View File

@@ -137,6 +137,10 @@ export class HeroAttrsComp extends ecs.Comp {
if(!isValue){ if(!isValue){
addValue = value * this.Attrs[Attrs.MP_MAX]; addValue = value * this.Attrs[Attrs.MP_MAX];
} }
let heroView = this.ent.get(HeroViewComp);
if(heroView){
heroView.mp_add(addValue);
}
this.mp += addValue; this.mp += addValue;
this.mp = Math.max(0, Math.min(this.mp, this.Attrs[Attrs.MP_MAX])); this.mp = Math.max(0, Math.min(this.mp, this.Attrs[Attrs.MP_MAX]));
} }

View File

@@ -174,13 +174,7 @@ export class HeroViewComp extends CCComp {
this.top_node.getChildByName("mp").getChildByName("mpb").getComponent(ProgressBar).progress = mp / mp_max; this.top_node.getChildByName("mp").getChildByName("mpb").getComponent(ProgressBar).progress = mp / mp_max;
}, 0.15); }, 0.15);
} }
private pow_show(pow: number, pow_max: number) {
if(!this.top_node.active) return
this.top_node.getChildByName("pow").getComponent(ProgressBar).progress = pow / pow_max;
this.scheduleOnce(() => {
this.top_node.getChildByName("pow").getChildByName("mpb").getComponent(ProgressBar).progress = pow / pow_max;
}, 0.15);
}
/** 升级特效 */ /** 升级特效 */
private lv_up() { private lv_up() {
var path = "game/skill/buff/buff_lvup"; var path = "game/skill/buff/buff_lvup";
@@ -296,7 +290,7 @@ export class HeroViewComp extends CCComp {
this.top_node.active=true this.top_node.active=true
this.hp_show(this.model.hp, this.model.Attrs[Attrs.HP_MAX]); this.hp_show(this.model.hp, this.model.Attrs[Attrs.HP_MAX]);
} }
mp(mp: number = 0) { mp_add(mp: number = 0) {
// 生命值更新由 Model 层处理,这里只负责视图表现 // 生命值更新由 Model 层处理,这里只负责视图表现
this.hp_tip(TooltipTypes.addmp, mp.toFixed(0)); this.hp_tip(TooltipTypes.addmp, mp.toFixed(0));
this.top_node.active=true this.top_node.active=true