Ejemplo n.º 1
0
 public void OnTriggerEnter2D(Collider2D col)
 {
     if (!col.isTrigger)
     {
         if (col.CompareTag(targetTag))
         {
             I_Killable killable = col.GetComponentInParent <I_Killable>();
             if (!killable.IsInvicible())
             {
                 float targetLife = killable.GetLife();
                 killable.TakeDamage(damage);
                 damage -= targetLife;
                 float coef = damage / maxDamage;
                 transform.localScale = startScale * coef;
                 if (damage <= 0)
                 {
                     DestroyBullet();
                 }
             }
         }
         else if (col.CompareTag("Environment"))
         {
             DestroyBullet();
         }
     }
 }
Ejemplo n.º 2
0
    public void OnTriggerEnter2D(Collider2D col)
    {
        if (!col.isTrigger)
        {
            if (col.CompareTag(targetTag))
            {
                I_Killable killable = col.GetComponentInParent <I_Killable>();
                if (!killable.IsInvicible())
                {
                    killable.TakeDamage(damage);
                }

                DestroyBullet();
            }
            else if (col.CompareTag("Environment"))
            {
                DestroyBullet();
            }
        }
    }