Пример #1
0
 /**
  * This method creates a trigger that causes an item to be collected,
  * @param other the collectible item is being collided with
  */
 void OnTriggerEnter(Collider other)
 {
     if (other.gameObject.tag == "WordGem")         //make word gems disappear
     {
         gemTracker.RemoveGem();                    //Update tracker by 1
         other.gameObject.SetActive(false);
         health.Heal(gemHealingPower);
     }
     if (other.gameObject.tag == "Food")         //make food disappear
     {
         other.gameObject.SetActive(false);
     }
 }
Пример #2
0
 /**
  * This method creates a trigger that causes an item to be collected,
  * increments a counter, and sets text showing info relating to what you collected
  * @param other the collectible item is being collided with
  */
 void OnTriggerEnter(Collider other)
 {
     if (other.gameObject.tag == "WordGem")         //make word gems disappear, increment counter, set text
     {
         other.gameObject.SetActive(false);
         gemTracker.RemoveGem();                             //Update gem tracker by removing a Gem
         wordCount++;
         atLeastOneGemCollected = true;
         SetWordCountText();
         SetWordText();
     }
     if (other.gameObject.tag == "Food")         //make food disappear, increment counter, set text
     {
         other.gameObject.SetActive(false);
         currentHealth++;
         SetCurrentHealthText();
     }
     if (other.gameObject.tag == "EnemyAmmo")
     {
         Destroy(other.gameObject);
         currentHealth--;
         if (currentHealth <= 0)
         {
             currentHealth = 0;
             SetCurrentHealthText();
             Application.LoadLevel(3);
         }
         else
         {
             SetCurrentHealthText();
         }
     }
     if (other.gameObject.tag == "MagicalGate")
     {
     }
 }