using UnityEngine; public class PlayerHealth : MonoBehaviour, IDamageable { [Header("Config")] [SerializeField] private PlayerStats stats; [SerializeField] private GameObject restartPanel; // 🔹 Tambahkan ini di Inspector private PlayerAnimations playerAnimations; private void Awake() { playerAnimations = GetComponent(); } private void Update() { if (stats.Health <= 0f) { PlayerDead(); } } public void TakeDamage(float amount) { if (stats.Health <= 0f) return; stats.Health -= amount; DamageManager.Instance.ShowDamageText(amount, transform); if (stats.Health <= 0f) { stats.Health = 0f; PlayerDead(); } } public void RestoreHealth(float amount) { stats.Health += amount; if (stats.Health > stats.MaxHealth) { stats.Health = stats.MaxHealth; } } public bool CanRestoreHealth() { return stats.Health > 0 && stats.Health < stats.MaxHealth; } private void PlayerDead() { playerAnimations.SetDeadAnimation(); // 🔹 Tampilkan panel restart if (restartPanel != null) { restartPanel.SetActive(true); } } }