优化死亡界面跳转

This commit is contained in:
2026-07-04 15:50:39 +08:00
parent c8e66f72b1
commit 3394e0a4e9
5 changed files with 207 additions and 133 deletions
@@ -16,6 +16,8 @@ namespace IndianOceanAssets.Engine2_5D
[SerializeField]
private bool isPlayer; // Is this the player?
private bool _isDead = false; // 防止重复触发死亡
// Initializes health
private void Start()
{
@@ -25,16 +27,25 @@ namespace IndianOceanAssets.Engine2_5D
// Applies damage and checks for death
public void Damage(int damageAmount)
{
if (_isDead) return; // 已死亡,不再处理
health -= damageAmount;
// If dead, trigger game over if player, then die
// If dead
if (health <= 0)
{
_isDead = true;
if (isPlayer)
{
// 玩家死亡:触发过场动画,不立即销毁(由 GameManager 处理)
GameManager.GameOver();
}
Die();
else
{
// 非玩家:正常播放死亡特效并销毁
Die();
}
}
}