コード例 #1
0
        private void OnMainMenuResultChanged(MainMenuResult new_result)
        {
            switch (new_result)
            {
            case MainMenuResult.START_GAME:
            {
                showNewEventControl();
            }
            break;

            case MainMenuResult.OPEN_SETTINGS:
            {
                setting_control.LastControl = main_menu;
                showControl(setting_control);
            }
            break;

            case MainMenuResult.INFO:
            {
                info_control.LastControl = main_menu;
                showControl(info_control);
            }
            break;

            case MainMenuResult.EXIT: this.Close(); break;

            default: { } break;
            }
        }
コード例 #2
0
ファイル: MainMenu.cs プロジェクト: MKRTeam/KeyboardSmasher
 private void BtnInfo_Click(object sender, EventArgs e)
 {
     Result = MainMenuResult.INFO;
 }
コード例 #3
0
ファイル: MainMenu.cs プロジェクト: MKRTeam/KeyboardSmasher
 private void btnExit_Click(object sender, EventArgs e)
 {
     Result = MainMenuResult.EXIT;
 }
コード例 #4
0
ファイル: MainMenu.cs プロジェクト: MKRTeam/KeyboardSmasher
 private void btnSettings_Click(object sender, EventArgs e)
 {
     Result = MainMenuResult.OPEN_SETTINGS;
 }
コード例 #5
0
ファイル: MainMenu.cs プロジェクト: MKRTeam/KeyboardSmasher
 private void btnStartGame_Click(object sender, EventArgs e)
 {
     Result = MainMenuResult.START_GAME;
 }
コード例 #6
0
 private void exitButton_Click(object sender, EventArgs e)
 {
     this.Result       = MainMenuResult.Quit;
     this.DialogResult = DialogResult.OK;
 }
コード例 #7
0
 private void settingsButton_Click(object sender, EventArgs e)
 {
     this.Result       = MainMenuResult.Settings;
     this.DialogResult = DialogResult.OK;
 }
コード例 #8
0
 private void saveGameButton_Click(object sender, EventArgs e)
 {
     this.Result       = MainMenuResult.SaveGame;
     this.DialogResult = DialogResult.OK;
 }
コード例 #9
0
ファイル: GUIController.cs プロジェクト: ricklove/BlockWars
    public MainMenuResult ShowMainMenu()
    {
        if (guiState != GUIState.MainMenu)
        {
            mainMenuIsShowingOptions = false;

            // Leave same as last play
            //mainMenuOptionHumanCount = 1;
            //mainMenuOptionComputerCount = 1;

            guiState = GUIState.MainMenu;
            guiResult = GUIResult.NotStarted;
            mainMenuResult = new MainMenuResult(guiResult, MainMenuAction.None, null);
        }

        return mainMenuResult;
    }
コード例 #10
0
ファイル: GUIController.cs プロジェクト: ricklove/BlockWars
    void OnGUI()
    {
        GUI.skin = mainSkin;
        // TODO: Use this method to make all GUI calls

        var padding = 10.0f;

        var sw = Screen.width;
        var sh = Screen.height;

        var w = (float)Mathf.Min(sw, 400);
        var h = (float)Mathf.Min(sh, 300);

        w = sw * 0.8f;
        h = sh * 0.8f;

        var l = (sw - w) / 2.0f;
        var t = (sh - h) / 2.0f;

        var fontSize = h / 10.0f;
        GUI.skin.button.fontSize = (int)fontSize;
        GUI.skin.label.fontSize = (int)fontSize;
        GUI.skin.box.fontSize = (int)fontSize;

        // Show Title screen
        if (guiState == GUIState.TitleScreen)
        {
            if (Time.time - titleScreenStartTime < titleScreenDisplayTimeSpan)
            {
                GUI.DrawTexture(new Rect(0, 0, Screen.width, Screen.height), titleBackgroundImage);
                GUI.DrawTexture(new Rect(0, 0, Screen.width, Screen.height), titleImage, ScaleMode.ScaleToFit);
                guiResult = GUIResult.Active;
            }
            else
            {
                guiResult = GUIResult.Finished;
            }
        }

        if (guiState == GUIState.MainMenu)
        {
            // Show New Game button with options
            // TODO: Only show Quit button for Desktops (Web/iPhone ignore this)

            if (guiResult == GUIResult.NotStarted)
            {
                guiResult = GUIResult.Active;
            }

            if (guiResult == GUIResult.Active)
            {

                var buttonCount = 3;
                buttonCount = ShouldShowQuitButton() ? buttonCount + 1 : buttonCount;

                // Button height (taking out the padding for each and the extra padding on top)
                var buttonHeight = ((h - padding) / buttonCount) - padding;

                GUILayout.BeginArea(new Rect(l, t, w, h));
                GUILayout.Space(padding);

                if (!mainMenuIsShowingOptions)
                {
                    if (GUILayout.Button("Quick Game", GUILayout.Height(buttonHeight)))
                    {
                        guiResult = GUIResult.Finished;
                        mainMenuResult = new MainMenuResult(guiResult, MainMenuAction.NewGame, new NewGameOptions(1, 1, false));
                    }
                    GUILayout.Space(padding);

                    if (GUILayout.Button("New Game", GUILayout.Height(buttonHeight)))
                    {
                        mainMenuIsShowingOptions = true;
                    }
                    GUILayout.Space(padding);

                    if (ShouldShowQuitButton())
                    {
                        if (GUILayout.Button("Quit", GUILayout.Height(buttonHeight)))
                        {
                            guiResult = GUIResult.Finished;
                            mainMenuResult = new MainMenuResult(guiResult, MainMenuAction.Close, null);
                        }
                        GUILayout.Space(padding);
                    }

                }
                else
                {
                    GUILayout.BeginHorizontal();
                    mainMenuOptionHumanCount = GUILayout.SelectionGrid(mainMenuOptionHumanCount, new string[]
          {
            "No Humans",
            "1 Human",
            "2 Humans",
            "3 Humans",
            "4 Humans"
          }, 1);
                    mainMenuOptionComputerCount = GUILayout.SelectionGrid(mainMenuOptionComputerCount, new string[]
          {
            "No Computers",
            "1 Computer",
            "2 Computers",
            "3 Computers",
            "4 Computers"
          }, 1);
                    GUILayout.EndHorizontal();

                    if (mainMenuOptionHumanCount + mainMenuOptionComputerCount > 1)
                    {
                        if (GUILayout.Button("Play", GUILayout.Height(buttonHeight)))
                        {
                            guiResult = GUIResult.Finished;
                            mainMenuResult = new MainMenuResult(guiResult, MainMenuAction.NewGame, new NewGameOptions(mainMenuOptionHumanCount, mainMenuOptionComputerCount, true));
                        }
                    }
                }

                GUILayout.EndArea();
            }
        }

        if (guiState == GUIState.EndOfGameReport)
        {
            if (Time.time - endOfGameStartTime < endOfGameDisplayTimeSpan)
            {

                GUI.Box(new Rect(l - padding, t - padding, w + 2 * padding, h + 2 * padding), "");
                GUILayout.BeginArea(new Rect(l, t, w, h));
                GUILayout.Space(padding);

                GUILayout.Box(endOfGameInfo.winnerName + " wins!");
                GUILayout.Space(padding);

                foreach (var loserName in endOfGameInfo.loserHumanNames)
                {
                    GUILayout.Box(loserName + " loses!");
                    GUILayout.Space(padding);
                }

                GUILayout.EndArea();

                guiResult = GUIResult.Active;
            }
            else
            {
                guiResult = GUIResult.Finished;
            }
        }
    }