From df3ad88c3e7df5f0de0e98a540112db25a3e7ec1 Mon Sep 17 00:00:00 2001 From: panw Date: Wed, 26 Nov 2025 10:14:06 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E8=8B=B1=E9=9B=84=E5=B1=9E=E6=80=A7):=20?= =?UTF-8?q?=E4=BF=AE=E5=A4=8DMP=E6=9B=B4=E6=96=B0=E6=97=B6=E8=A7=86?= =?UTF-8?q?=E5=9B=BE=E6=9C=AA=E5=90=8C=E6=AD=A5=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修改HeroAttrsComp在更新MP值时调用HeroViewComp的mp_add方法同步视图 重命名HeroViewComp的mp方法为mp_add以更准确描述其功能 移除HeroViewComp中未使用的pow_show方法 --- assets/script/game/hero/HeroAttrsComp.ts | 4 ++++ assets/script/game/hero/HeroViewComp.ts | 10 ++-------- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/assets/script/game/hero/HeroAttrsComp.ts b/assets/script/game/hero/HeroAttrsComp.ts index 67ccff60..9646a165 100644 --- a/assets/script/game/hero/HeroAttrsComp.ts +++ b/assets/script/game/hero/HeroAttrsComp.ts @@ -137,6 +137,10 @@ export class HeroAttrsComp extends ecs.Comp { if(!isValue){ addValue = value * this.Attrs[Attrs.MP_MAX]; } + 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])); } diff --git a/assets/script/game/hero/HeroViewComp.ts b/assets/script/game/hero/HeroViewComp.ts index b5e8a534..37c569cd 100644 --- a/assets/script/game/hero/HeroViewComp.ts +++ b/assets/script/game/hero/HeroViewComp.ts @@ -174,13 +174,7 @@ export class HeroViewComp extends CCComp { this.top_node.getChildByName("mp").getChildByName("mpb").getComponent(ProgressBar).progress = mp / mp_max; }, 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() { var path = "game/skill/buff/buff_lvup"; @@ -296,7 +290,7 @@ export class HeroViewComp extends CCComp { this.top_node.active=true this.hp_show(this.model.hp, this.model.Attrs[Attrs.HP_MAX]); } - mp(mp: number = 0) { + mp_add(mp: number = 0) { // 生命值更新由 Model 层处理,这里只负责视图表现 this.hp_tip(TooltipTypes.addmp, mp.toFixed(0)); this.top_node.active=true