private void Update() { if (HealthSystem.Health == 0) { OnEnemyDamaged?.Invoke(); } }
public void GetDamage(int amount) { anim.SetTrigger("isAttacked"); currentHealth -= amount; OnEnemyDamaged?.Invoke(); if (currentHealth <= 0) { Die(); } }
protected virtual void Awake() { controller = GetComponent <CharacterController>(); Damageable damageable; if (TryGetComponent(out damageable)) { damageable.OnTakeDamage += d => OnEnemyDamaged?.Invoke(this); } }
public void TakeDamage(int damage) { if (_healthComp.TakeDamage(damage)) { OnEnemyDamaged?.Invoke(this, damage); if (_currentState != States.Death) { _animator.Play("OnHit"); } } }
public void TakeDamage(int damage) { _currentHealth -= damage; _hurtThisBeat = true; OnEnemyDamaged?.Invoke(damage); if (_currentHealth <= 0) { _currentHealth = 0; OnEnemyKilled?.Invoke(); GameMaster.Find <GameMaster>().TransitionTo(GameState.WaveEnded); } //TODO raise eventy }