Beispiel #1
0
 private void OnEnable()
 {
     gameoverUI = FindObjectOfType <Gameover>();
     spawner    = FindObjectOfType <Spawn>();
     if (!IsValidGridPos())
     {
         gameoverUI.EndGame();
         Destroy(gameObject);
     }
 }
Beispiel #2
0
 public void touchOrb(OrbScript orb)
 {
     if (!paused)
     {
         if (orb.GetOrbColor() == OrbScript.OrbColor.Red)
         {
             GetComponent <AudioSource>().clip = balloon;
             GetComponent <AudioSource>().Play();
             KillAllOrbs();
             gameover.EndGame();
             music.Stop();
         }
         else
         {
             if (orb.GetOrbColor() == OrbScript.OrbColor.Gold)
             {
                 GetComponent <AudioSource>().clip = goldPop;
                 GetComponent <AudioSource>().Play();
             }
             else
             {
                 int randomSound = Random.Range(0, 2);
                 GetComponent <AudioSource>().clip = pop[randomSound];
                 GetComponent <AudioSource>().Play();
             }
             if (orb.GetOrbColor() == OrbScript.OrbColor.Gold)
             {
                 score += 5;
             }
             else
             {
                 score++;
             }
             scoreText.text = "" + score;
         }
         deathOrb(orb);
     }
 }