| | |
| | | |
| | | public class Damageable : MonoBehaviour |
| | | { |
| | | // ONLY FOR DEBUG USE |
| | | [SerializeField] |
| | | private bool selfDamage = false; |
| | | Animator animator; |
| | | |
| | | [SerializeField] |
| | | private int _maxHealth = 100; |
| | | [SerializeField] |
| | | private int _health; |
| | | private int _health = 100; |
| | | [SerializeField] |
| | | private bool _isAlive = true; |
| | | [SerializeField] |
| | |
| | | get { return _health; } |
| | | set |
| | | { |
| | | if (value > MaxHealth) |
| | | { |
| | | _health = MaxHealth; |
| | | } |
| | | else |
| | | { |
| | | _health = value; |
| | | } |
| | | if (value <= 0) |
| | | { |
| | | IsAlive = false; |
| | |
| | | |
| | | private void Awake() |
| | | { |
| | | Health = MaxHealth; |
| | | //Health = MaxHealth; |
| | | animator = GetComponent<Animator>(); |
| | | } |
| | | private void Update() |
| | |
| | | timeSinceHit += Time.deltaTime; |
| | | } |
| | | } |
| | | if (selfDamage) |
| | | { |
| | | Hit(10); |
| | | } |
| | | } |
| | | |
| | | public void Hit(int damage) |