private void OnGUI() { controller = SSDirector.getInstance().CurrentSceneController as ISceneController; string buttonText = ""; if (controller.getGameState().Equals(GameState.START) || controller.getGameState().Equals(GameState.PAUSE)) { buttonText = "Start"; } if (controller.getGameState().Equals(GameState.LOSE)) { buttonText = "Restart"; GUI.Label(new Rect(Screen.width / 2 - 40, Screen.height / 2 + 100, 200, 50), "Game Over!", finishStyle); } if (controller.getGameState().Equals(GameState.WIN)) { buttonText = "Restart"; GUI.Label(new Rect(Screen.width / 2 - 40, Screen.height / 2 + 100, 200, 50), "You Win!", finishStyle); } if (controller.getGameState().Equals(GameState.RUNNING)) { buttonText = "Pause"; } GUI.Label(new Rect(Screen.width / 2 - 400, Screen.height / 2 - 200, 100, 50), "Score: " + controller.GetScore().ToString(), scoreStyle); //GUI.Label(new Rect(Screen.width / 2 - 50, Screen.height / 2 - 350, 100, 50), // "Time: " + SSDirector.getInstance().leaveSeconds.ToString(), countDownStyle); if (GUI.Button(new Rect(Screen.width / 2 - 60, Screen.height / 2 + 150, 100, 50), buttonText, buttonStyle)) { // 按下按钮控制游戏状态 if (buttonText == "Pause") { controller.Pause(); } else if (buttonText == "Start") { controller.Begin(); } else if (buttonText == "Restart") { controller.Restart(); } } }
void OnGUI() { if (isStart == false) { if (GUI.Button(new Rect(200, 200, 240, 80), "Start Game")) { controller.LoadResources(); isStart = true; } } else { if (isPause == true) { GUI.Label(new Rect(310, 400, 120, 20), "waiting!!!"); } if (GUI.Button(new Rect(570, 5, 60, 20), "Resume")) { controller.Resume(); isPause = false; } if (GUI.Button(new Rect(505, 5, 60, 20), "Pause")) { controller.Pause(); isPause = true; } if (isPause == false) { if (GUI.Button(new Rect(5, 5, 100, 20), "Speed Up")) { action.SpeedUp(); } if (GUI.Button(new Rect(110, 5, 100, 20), "Speed Down")) { action.SpeedDown(); } if (GUI.Button(new Rect(215, 5, 100, 20), "Restart")) { isStart = false; isPause = false; action.GameOver(); } } } }