using UnityEngine; public class PlayerHealth : MonoBehaviour { public int maxHealth = 100; private int currentHealth; void Start() { currentHealth = maxHealth; // Force the UI to update on frame 1 UIManager.Instance.UpdatePlayerHealth(currentHealth, maxHealth); } public void TakeDamage(int damage) { currentHealth -= damage; currentHealth = Mathf.Max(0, currentHealth); // Prevent negative health UIManager.Instance.UpdatePlayerHealth(currentHealth, maxHealth); if (currentHealth <= 0) { Die(); } } private void Die() { Debug.Log("Player has fallen! The horde wins."); // TODO: Trigger player death animation and game over screen } public void Heal(int amount) { currentHealth += amount; currentHealth = Mathf.Min(currentHealth, maxHealth); // Prevent overhealing UIManager.Instance.UpdatePlayerHealth(currentHealth, maxHealth); Debug.Log($"Player Healed for {amount}!"); } }