// Update is called once per frame void Update() { if (currentGameState == GameState.PlayingLevel) { currentTime -= Time.deltaTime; if (grid.GridComplete() || currentTime < 0) { currentGameState = GameState.EndLevel; EndLevel(); } scoreText.text = currentScore.ToString(); timeText.text = string.Format("{0:0}:{1:00}", currentTime / 60, currentTime % 60); } if (currentGameState == GameState.EndLevel) { RestartGameMsg.SetActive(true); grid.gameObject.SetActive(false); topMagnet.gameObject.SetActive(false); leftMagnet.gameObject.SetActive(false); gun.gameObject.SetActive(false); if (Input.GetButtonDown("Restart")) { StartLevel(); } } }
// Update is called once per frame void Update() { if (currentGameState == GameState.PlayingLevel) { currentTime -= Time.deltaTime; if (grid.GridComplete() || currentTime < 0) { currentGameState = GameState.EndLevel; EndLevel(); } scoreText.text = currentScore.ToString(); timeText.text = string.Format("{0:0}:{1:00}", currentTime / 60, currentTime % 60); } if (currentGameState == GameState.EndLevel) { gameText.gameObject.SetActive(true); grid.gameObject.SetActive(false); topMagnet.gameObject.SetActive(false); leftMagnet.gameObject.SetActive(false); gun.gameObject.SetActive(false); if (Input.GetButtonDown("Continue")) { if (currentLevelNumber > levelNames.Count - 1) { StartLevel(); } else { PlayerPrefs.SetInt("Score", currentScore); Application.LoadLevel("ScoreScreen"); } } else if (Input.GetButtonDown("Restart")) { currentLevelNumber--; currentScore = 0; StartLevel(); } } if (currentGameState == GameState.EndGame) { if (Input.GetButtonDown("Restart")) { StartGame(); } } }