void Awake() { SP = this; foundGems = 0; gameState = MarbleGameState.playing; totalGems = GameObject.FindGameObjectsWithTag("Pickup").Length; Time.timeScale = 1.0f; }
public void WonGame() { Time.timeScale = 0.0f; //Pause game gameState = MarbleGameState.won; }
public void SetGameOver() { Time.timeScale = 0.0f; //Pause game gameState = MarbleGameState.lost; }
void OnGUI() { GUILayout.Label(" Found gems: "+foundGems+"/"+totalGems ); if (gameState == MarbleGameState.lost) { GUILayout.Label("You Lost!"); if(GUILayout.Button("Try again") ){ Application.LoadLevel(Application.loadedLevel); } } else if (gameState == MarbleGameState.won) { GUILayout.Label("You won!"); if(GUILayout.Button("Play again") ){ Application.LoadLevel(Application.loadedLevel); } } else { float curCount = maxTime - (Time.time - startTime), minutes = curCount / 60, seconds = curCount % 60, miliseconds = (curCount * 100) % 100; if (curCount <= 0) { gameState = MarbleGameState.lost; paused = true; } string countText = string.Format("{0:00}:{1:00}:{2:000}", minutes, seconds, miliseconds); GUILayout.Label(countText); paused = GUILayout.Toggle(paused, "Pause"); } }