Esempio n. 1
0
 private void ProcessHit(DamageDealer damageDealer)
 {
     if (damageDealer == null)
     {
         return;
     }
     health -= damageDealer.GetDamage();
     damageDealer.Destroy();
     Instantiate(hitVfx, gameObject.transform.position, Quaternion.identity);
     if (health < 0)
     {
         Die();
     }
 }
Esempio n. 2
0
    private void OnTriggerEnter2D(Collider2D collision)
    {
        DamageDealer damageDealer = collision.gameObject.GetComponent <DamageDealer>();

        if (damageDealer == null)
        {
            return;
        }
        health -= damageDealer.GetDamage();
        if (!collision.gameObject.tag.Equals("player"))
        {
            damageDealer.Destroy();
        }
        if (health <= 0)
        {
            Die();
        }
        else
        {
            Instantiate(hitVfx, gameObject.transform.position, Quaternion.identity);
        }
    }