Example #1
0
 private void Update()
 {
     if (HealthSystem.Health == 0)
     {
         OnEnemyDamaged?.Invoke();
     }
 }
Example #2
0
 public void GetDamage(int amount)
 {
     anim.SetTrigger("isAttacked");
     currentHealth -= amount;
     OnEnemyDamaged?.Invoke();
     if (currentHealth <= 0)
     {
         Die();
     }
 }
Example #3
0
    protected virtual void Awake()
    {
        controller = GetComponent <CharacterController>();

        Damageable damageable;

        if (TryGetComponent(out damageable))
        {
            damageable.OnTakeDamage += d => OnEnemyDamaged?.Invoke(this);
        }
    }
Example #4
0
 public void TakeDamage(int damage)
 {
     if (_healthComp.TakeDamage(damage))
     {
         OnEnemyDamaged?.Invoke(this, damage);
         if (_currentState != States.Death)
         {
             _animator.Play("OnHit");
         }
     }
 }
Example #5
0
    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
    }