fix:解决敌人死亡执行瞬间多次执行方法问题

This commit is contained in:
bzx
2025-08-14 18:49:18 +08:00
parent 6758a7189e
commit 4019102b5b
2 changed files with 6 additions and 3 deletions

View File

@@ -181,8 +181,9 @@ public class Enemy : MonoBehaviour
if(_sender.GetComponent<EnemyBullet>()!=null)
return;
Damage(value,(bool)info);
if (health <= 0)
if (health <= 0&& !isDead)
{
Debug.Log("敌人死亡");
Dead();
}
}

View File

@@ -37,16 +37,18 @@ public class EnemyTa : Enemy,IDamagable
public override void Update()
{
base.Update();
if (GameManager.Ins.GetCurEnemyListCount() <= 0&& !isDie)
if (GameManager.Ins.GetCurEnemyListCount() <= 0&& !isDead)
{
Debug.Log("敌人死亡2");
Dead();
}
}
public override void Dead()
{
if(isDead)
return;
base.Dead();
isDie = true;
GameManager.Ins.CurLevelWin(transform.position.ReflectVectorXOZ());
GameInit.Ins.PlayAudio("1.7",GameInit.Ins.self.transform,true);
}