Beispiel #1
0
 //Runs when object collides with a trigger collider
 void OnTriggerEnter(Collider other)
 {
     if (other.gameObject.CompareTag("Collectible"))
     {
         //Destroy(other.gameObject);
         other.gameObject.SetActive(false);
         if (other.gameObject.name == "Chip Spice")
         {
             score += 250;
         }
         else if (other.gameObject.name == "Chip Spice Bottle")
         {
             score += 500;
         }
         else if (other.gameObject.name == "Chips")
         {
             score += 750;
         }
         else
         {
             score += 100;
         }
     }
     if (other.gameObject.CompareTag("Obstacle"))
     {
         //Game over
         PersistentClass.setScore(score);
         if (score > PersistentClass.getHighScore())
         {
             PersistentClass.setHighScore(score);
         }
         Application.LoadLevel(0);
     }
 }