Ejemplo 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();
     }
 }
Ejemplo 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);
        }
    }