Example #1
0
 void Update()
 {
     hideGameStart();
     if (restart)
     {
         if (Input.GetKeyDown(KeyCode.R))
         {
             //Application.LoadLevel(Application.loadedLevel);
             SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex);
         }
     }
     //Upgrade Abfrage
     if (score >= 40 && !gameOver)
     {
         showUpgradeText();
         if (score < 40)
         {
             hideUpgradeText();
         }
         if (Input.GetKeyDown(KeyCode.U))
         {
             hideUpgradeText();
             GameObject player1Obj = GameObject.FindWithTag("Player");
             if (player1Obj != null)
             {
                 PlayerController player1 = player1Obj.GetComponent <PlayerController> ();
                 player1.increaseFireRate();
             }
             GameObject player2Obj = GameObject.FindWithTag("Player2");
             if (player2Obj != null)
             {
                 Player2Controller player2 = player2Obj.GetComponent <Player2Controller> ();
                 player2.increaseFireRate();
             }
             AddScore(-40);
         }
     }
     //GameOver bei Score kleiner als 0
     if (score < 0 && gameOver != true)
     {
         GameOver();
         resetWaveText();
         GameObject player2Obj = GameObject.FindWithTag("Player2");
         if (player2Obj != null)
         {
             Player2Controller player2 = player2Obj.GetComponent <Player2Controller> ();
             Instantiate(playerExplosion, player2.transform.position, player2.transform.rotation);
             Destroy(player2.gameObject);
         }
         GameObject player1Obj = GameObject.FindWithTag("Player");
         if (player1Obj != null)
         {
             PlayerController player1 = player1Obj.GetComponent <PlayerController> ();
             Instantiate(playerExplosion, player1.transform.position, player1.transform.rotation);
             Destroy(player1.gameObject);
         }
     }
 }