Example #1
0
 void OnTriggerEnter2D(Collider2D collider)
 {
     if (collider.tag == "Bullet")
     {
         if (lifePoints <= 0)
         {
             ai.Die();
             Destroy(collider.gameObject);
         }
         else
         {
             Destroy(collider.gameObject);
             //gameObject.GetComponent<Rigidbody2D>().velocity = new Vector2(0f, 0f);
             lifePoints -= collider.GetComponent <BulletMovement>().damage;
             if (lifePoints < totalLifePoints / 2)
             {
                 ai.BecomeMad(true);
             }
         }
     }
     if (collider.tag == "SlashPlayer")
     {
         if (lifePoints <= 0)
         {
             ai.Die();
             Destroy(collider.gameObject);
         }
         else
         {
             Destroy(collider.gameObject);
             //gameObject.GetComponent<Rigidbody2D>().velocity = new Vector2(0f, 0f);
             lifePoints -= 20;
             if (lifePoints < totalLifePoints / 2)
             {
                 ai.BecomeMad(true);
             }
         }
     }
 }