fix(战斗系统): 修复角色状态切换和击退效果的问题

- 在HeroMove和MonMove系统中增加攻击状态检查,避免攻击时被错误切换为待机状态
- 为HeroAtkSystem添加受击者击退效果
- 优化HeroViewComp的击退逻辑,包括英雄和怪物,并修复重复触发问题
- 修复怪物死亡后状态切换问题
This commit is contained in:
walkpan
2026-01-03 13:41:08 +08:00
parent 1cce4ce361
commit 08c153ee5d
4 changed files with 34 additions and 13 deletions

View File

@@ -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