优化死亡界面跳转
This commit is contained in:
@@ -348,7 +348,7 @@ MonoBehaviour:
|
||||
m_Script: {fileID: 11500000, guid: f9e36f6d2e0ea0541bad29e784e0841b, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
maxHealth: 100
|
||||
maxHealth: 5
|
||||
deathEffect: {fileID: 4806121257990350900, guid: f19c76183b5e22e44a73655dc18f1a92, type: 3}
|
||||
isPlayer: 1
|
||||
--- !u!114 &4071397948156435190
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user