Finalized health bar and obstacle course code

This commit is contained in:
djkellerman
2025-04-17 23:33:03 -04:00
parent 7f4556853f
commit c2463da317
11 changed files with 1544 additions and 2028 deletions

View File

@@ -42,8 +42,8 @@ public class HealthBarManager : MonoBehaviour
// Subscribe to the player's death and respawn events
var damageable = player.GetComponent<Damageable>();
//damageable.OnPlayerDeath += HandlePlayerDeath;
//damageable.OnPlayerRespawn += HandlePlayerRespawn;
damageable.OnPlayerDeath += HandlePlayerDeath;
damageable.OnPlayerRespawn += HandlePlayerRespawn;
}
}
}
@@ -86,8 +86,8 @@ public class HealthBarManager : MonoBehaviour
{
if (player != null && player.TryGetComponent<Damageable>(out var damageable))
{
//damageable.OnPlayerDeath -= HandlePlayerDeath;
//damageable.OnPlayerRespawn -= HandlePlayerRespawn;
damageable.OnPlayerDeath -= HandlePlayerDeath;
damageable.OnPlayerRespawn -= HandlePlayerRespawn;
}
}
}

View File

@@ -21,8 +21,15 @@ public class WinScreen : MonoBehaviour
}
}
public void ShowWinScreen(int player) // Triggers the win screen to appear
public void ShowWinScreen(int player)
{
Debug.Log($"ShowWinScreen called for Player {player}");
if (player - 1 < 0 || player - 1 >= GameManager.playerColors.Count)
{
Debug.LogError("Invalid player index or playerColors not initialized.");
return;
}
foreach (TextMeshProUGUI playerText in playerTexts)
{
playerText.text = "Player " + player;
@@ -32,7 +39,15 @@ public class WinScreen : MonoBehaviour
}
}
GetComponent<Animator>().SetTrigger("win");
Animator animator = GetComponent<Animator>();
if (animator == null)
{
Debug.LogError("Animator component missing on WinScreen.");
return;
}
animator.SetTrigger("win");
}
}
}