From 08c153ee5dc3838371a7be18d4229bf7a8e99cdf Mon Sep 17 00:00:00 2001 From: walkpan Date: Sat, 3 Jan 2026 13:41:08 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E6=88=98=E6=96=97=E7=B3=BB=E7=BB=9F):=20?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E8=A7=92=E8=89=B2=E7=8A=B6=E6=80=81=E5=88=87?= =?UTF-8?q?=E6=8D=A2=E5=92=8C=E5=87=BB=E9=80=80=E6=95=88=E6=9E=9C=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 在HeroMove和MonMove系统中增加攻击状态检查,避免攻击时被错误切换为待机状态 - 为HeroAtkSystem添加受击者击退效果 - 优化HeroViewComp的击退逻辑,包括英雄和怪物,并修复重复触发问题 - 修复怪物死亡后状态切换问题 --- assets/script/game/hero/HeroAtkSystem.ts | 5 +++++ assets/script/game/hero/HeroMove.ts | 4 +++- assets/script/game/hero/HeroViewComp.ts | 24 +++++++++++++++--------- assets/script/game/hero/MonMove.ts | 14 +++++++++++--- 4 files changed, 34 insertions(+), 13 deletions(-) diff --git a/assets/script/game/hero/HeroAtkSystem.ts b/assets/script/game/hero/HeroAtkSystem.ts index ffd3f25f..40331a48 100644 --- a/assets/script/game/hero/HeroAtkSystem.ts +++ b/assets/script/game/hero/HeroAtkSystem.ts @@ -176,6 +176,11 @@ export class HeroAtkSystem extends ecs.ComblockSystem implements ecs.ISystemUpd TAttrsComp.hp -= damage; // 应用伤害到数据层 + // 受击者产生击退效果 + if (damage > 0 && targetView) { + targetView.back(); + } + smc.updateHeroInfo(TAttrsComp); // 更新英雄数据到 VM if (this.debugMode) { const casterName = damageEvent.caster?.ent?.get(HeroAttrsComp)?.hero_name || "未知"; diff --git a/assets/script/game/hero/HeroMove.ts b/assets/script/game/hero/HeroMove.ts index de2cc5af..d535c51e 100644 --- a/assets/script/game/hero/HeroMove.ts +++ b/assets/script/game/hero/HeroMove.ts @@ -123,7 +123,9 @@ export class HeroMoveSystem extends ecs.ComblockSystem implements ecs.ISystemUpd move.direction = 1; } } else { - view.status_change("idle"); + if (!model.is_atking) { + view.status_change("idle"); + } // 因为敌人在面前而暂时停止,不设置moving为false,保持检查状态 } } diff --git a/assets/script/game/hero/HeroViewComp.ts b/assets/script/game/hero/HeroViewComp.ts index e71797ff..3551a4ca 100644 --- a/assets/script/game/hero/HeroViewComp.ts +++ b/assets/script/game/hero/HeroViewComp.ts @@ -316,6 +316,7 @@ export class HeroViewComp extends CCComp { } /** 状态切换(动画) */ status_change(type:string){ + if(this.status === type) return; this.status = type; if(this.model.is_dead || this.model.is_reviving) return if(type === "idle"){ @@ -453,10 +454,10 @@ export class HeroViewComp extends CCComp { back(){ // 🔥 防止重复调用后退动画 if (this.isBackingUp) return; - + this.isBackingUp = true; // 🔥 设置后退状态 + if(this.model.fac==FacSet.MON) { - this.isBackingUp = true; // 🔥 设置后退状态 - let tx=this.node.position.x+30 + let tx=this.node.position.x+5 if(tx > 320) tx=320 tween(this.node) .to(0.1, { position:v3(tx,this.node.position.y,0)}) @@ -465,12 +466,17 @@ export class HeroViewComp extends CCComp { }) .start() } - //英雄不再后退 - // if(this.model.fac==FacSet.HERO) { - // let tx=this.node.position.x-30 - // if(tx < -320) tx=-320 - // tween(this.node).to(0.1, { position:v3(tx,this.node.position.y,0)}).start() - // } + + if(this.model.fac==FacSet.HERO) { + let tx=this.node.position.x-5 + if(tx < -320) tx=-320 + tween(this.node) + .to(0.1, { position:v3(tx,this.node.position.y,0)}) + .call(() => { + this.isBackingUp = false; // 🔥 动画完成后重置状态 + }) + .start() + } } // 伤害计算和战斗逻辑已迁移到 HeroBattleSystem diff --git a/assets/script/game/hero/MonMove.ts b/assets/script/game/hero/MonMove.ts index 24a88afe..59c48012 100644 --- a/assets/script/game/hero/MonMove.ts +++ b/assets/script/game/hero/MonMove.ts @@ -41,12 +41,18 @@ export class MonMoveSystem extends ecs.ComblockSystem implements ecs.ISystemUpda update(e: ecs.Entity) { if (!smc.mission.play || smc.mission.pause) return; + + const view = e.get(HeroViewComp); + // 如果英雄死亡(停止怪物行动标志为true),则停止怪物移动 - if (smc.mission.stop_mon_action) return; + if (smc.mission.stop_mon_action) { + view.status_change("idle"); + return; + } const move = e.get(MonMoveComp); const model = e.get(HeroAttrsComp); - const view = e.get(HeroViewComp); + // const view = e.get(HeroViewComp); // 只处理怪物 if (model.fac !== FacSet.MON) return; @@ -91,7 +97,9 @@ export class MonMoveSystem extends ecs.ComblockSystem implements ecs.ISystemUpda move.moving = false; } } else { - view.status_change("idle"); + if (!model.is_atking) { + view.status_change("idle"); + } } }