using Sirenix.OdinInspector; using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.Events; using UnityEngine.EventSystems; public class HealthComponent : MonoBehaviour { [ReadOnly] [SerializeField] private int health; [ReadOnly] [SerializeField] private bool isDead; public UnityEvent onDied; [Button] public void Setup() { health = 100; isDead = false; } public void TakeDamage(int damage) { health -= damage; if (health < 0) { health = 0; } if (health == 0) { isDead = true; onDied.Invoke(); } } [Button] private void Take10Damage() { TakeDamage(10); } [Button] private void Kill() { TakeDamage(health); } }