コード例 #1
0
 void OnTriggerEnter2D(Collider2D other)
 {
     if (other.gameObject.tag == "Projectile")
     {
         Projectile incoming = other.gameObject.GetComponent <Projectile>();
         if (incoming.playerTag != gameObject.tag)//Used to make sure the player doens't hit itself
         {
             if (!GameManager.instance.GameOver())
             {
                 GameManager.instance.EndGame(gameObject.tag);
                 gameObject.SetActive(false);
             }
             incoming.Impact();
         }
     }
     //The rest of these if statements handle powerup collision
     else if (other.gameObject.tag == "Fire Cooldown Up")
     {
         playerStats.FireCooldownUp();
         Destroy(other.gameObject);
     }
     else if (other.gameObject.tag == "Fire Speed Up")
     {
         playerStats.FireSpeedUp();
         Destroy(other.gameObject);
     }
     else if (other.gameObject.tag == "Starburst")
     {
         projectileShooter.Starburst();
         Destroy(other.gameObject);
     }
     else if (other.gameObject.tag == "Trishot")
     {
         playerStats.ActivateTrishot();
         Destroy(other.gameObject);
     }
 }