コード例 #1
0
 public void PreGame()
 {
     state = GameStates.PreGame;
     PregameCanvas.GetComponent <Canvas>().enabled  = true;
     GameCanvas.GetComponent <Canvas>().enabled     = false;
     GameOverCanvas.GetComponent <Canvas>().enabled = false;
     mainCamera.GetComponent <Camera>().enabled     = true; //Show game through main camera
     ResetGame();
     player.GetComponent <Player>().ResetPlayer();
 }
コード例 #2
0
 public void GameOn()
 {
     Cursor.visible   = false;
     Cursor.lockState = CursorLockMode.Locked;
     state            = GameStates.GameOn;
     GameCanvas.GetComponent <Canvas>().enabled     = true;
     PregameCanvas.GetComponent <Canvas>().enabled  = false;
     GameOverCanvas.GetComponent <Canvas>().enabled = false;
     mainCamera.GetComponent <Camera>().enabled     = false; //Show game through player camera
     InvokeRepeating("IncreaseDifficulty", secondsPerUpDifficulty, secondsPerUpDifficulty);
     InvokeRepeating("UpdateTime", 1, 1);                    //Update the time the game has been going on for once per second
     foreach (SpawnPoints point in FindObjectsOfType <SpawnPoints>())
     {
         point.InvokeRepeating("SpawnEnemy", point.initialRoundSpawnDelay, point.timeBetweenSpawns);
     }
 }
コード例 #3
0
 public void GameOver()
 {
     Cursor.visible   = true;
     Cursor.lockState = CursorLockMode.None;
     state            = GameStates.GameOver;
     CheckHighScore(playerScore);
     CheckHighTime((minutes * 60) + seconds);
     GameOverCanvas.transform.Find("Score").GetComponent <Text>().text = playerScore.ToString();
     GameOverCanvas.GetComponent <Canvas>().enabled = true;
     PregameCanvas.GetComponent <Canvas>().enabled  = false;
     GameCanvas.GetComponent <Canvas>().enabled     = false;
     mainCamera.GetComponent <Camera>().enabled     = true; //Show game through main camera
     foreach (Enemy enemy in FindObjectsOfType <Enemy>())
     {
         Destroy(enemy.gameObject);
     }
     foreach (SpawnPoints point in FindObjectsOfType <SpawnPoints>())
     {
         point.CancelInvoke("SpawnEnemy");
     }
     CancelInvoke("UpdateTime");
     CancelInvoke("IncreaseDifficulty");
     GameOverCanvas.transform.Find("Time Survived").GetComponent <Text>().text = time.text;
 }