Ejemplo n.º 1
0
 private void OnTriggerEnter2D(Collider2D collision)
 {
     if (collision.CompareTag("Enemy"))
     {
         EnemyHealthSystem hs = collision.GetComponent <EnemyHealthSystem>();
         if (hs)
         {
             hs.SetDamage(meleeDamage);
         }
     }
     else if (collision.CompareTag("Boss"))
     {
         BossHealthSystem bs = collision.GetComponent <BossHealthSystem>();
         if (bs)
         {
             bs.SetDamage(meleeDamage);
         }
     }
     else if (collision.CompareTag("Enemy"))
     {
         EnemyMeleeHealthSystem hms = collision.GetComponent <EnemyMeleeHealthSystem>();
         if (hms)
         {
             hms.SetDamage(meleeDamage);
         }
     }
 }
Ejemplo n.º 2
0
    public bool DestroyThisGameObject = true; //Destruir las balas

    //Compara tag enemy para aplicar daño
    private void OnTriggerEnter2D(Collider2D collision)
    {
        if (collision.CompareTag("Enemy"))
        {
            EnemyHealthSystem hs = collision.GetComponent <EnemyHealthSystem>();
            if (hs)
            {
                hs.SetDamage(Damage);

                if (DestroyThisGameObject)
                {
                    Destroy(gameObject);
                }
            }
            //Compara tag boss para aplicar daño
        }
        else if (collision.CompareTag("Boss"))
        {
            BossHealthSystem bs = collision.GetComponent <BossHealthSystem>();
            if (bs)
            {
                bs.SetDamage(Damage);

                if (DestroyThisGameObject)
                {
                    Destroy(gameObject);
                }
            }
        }
        //Compara tag enemymelee para aplicar daño
        else if (collision.CompareTag("EnemyMelee"))
        {
            EnemyMeleeHealthSystem hms = collision.GetComponent <EnemyMeleeHealthSystem>();
            if (hms)
            {
                hms.SetDamage(Damage);

                if (DestroyThisGameObject)
                {
                    Destroy(gameObject);
                }
            }
        }
    }