Exemplo n.º 1
0
    void OnGUI()

    {
        width  = Screen.width / 12;
        height = Screen.height / 12;

        if (sceneController.isStarted == false)
        {
            if (GUI.Button(new Rect(castw(2f) + 20, casth(6f) + 60, 50, 50), "Start"))
            {
                action.StartGame();
            }
        }
        else
        {
            if (GUI.Button(new Rect(width + 120, height, 60, 30), "Restart"))
            {
                action.Restart();
            }

            if (GUI.Button(new Rect(width + 200, height, 80, 30), "Change"))
            {
                action.ChangeActionManager();

                action.Restart();
            }

            if (sceneController.isPaused == true)
            {
                if (GUI.Button(new Rect(castw(2f) + 20, casth(6f) + 60, 100, 50), "Next Round"))
                {
                    //  if (sceneController.score >= sceneController.round*50)
                    action.Resume();


                    //  if (GUI.Button(new Rect(castw(2f) + 20, casth(6f) + 60, 50, 50), "GameOver"))
                    // {
                    //     action.Restart();
                    //      }

                    //      }
                }
            }

            GUI.TextArea(new Rect(width, height, 100, 30), "Score:" + sceneController.score.ToString());
            GUI.TextArea(new Rect(width, height + 50, 100, 30), "Round : " + sceneController.round.ToString());
        }
    }
Exemplo n.º 2
0
    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();
            }
        }
    }