Example #1
0
 private void OnTriggerExit2D(Collider2D other)
 {
     if (other.CompareTag(GameProperties.tagBoundary))
     {
         health = 0;
         EnemyManager.amountEnemies--;
         Murdered?.Invoke(this);
         gameObject.SetActive(false);
     }
 }
Example #2
0
    public void TakeDamage(float damage)
    {
        health -= damage;

        if (health <= 0)
        {
            Murdered?.Invoke();
            gameObject.SetActive(false);
        }
    }
Example #3
0
 private void OnTriggerEnter2D(Collider2D other)
 {
     if (LayerMask.LayerToName(other.gameObject.layer) == GameProperties.layerPlayer)
     {
         other.GetComponent <PlayerController>().TakeDamage(damageCollision);
         health = 0;
         EnemyManager.amountEnemies--;
         Murdered?.Invoke(this);
         gameObject.SetActive(false);
     }
 }
Example #4
0
    public void TakeDamage(float damage)
    {
        if (health <= 0)
        {
            return;
        }

        health -= damage;

        if (health <= 0)
        {
            EnemyManager.amountEnemies--;
            Murdered?.Invoke(this);
            gameObject.SetActive(false);
        }
    }