Exemple #1
0
        /// <summary>
        /// The setup menu was clicked, perform the button's action.
        /// </summary>
        /// <param name="button">the button pressed</param>
        private static void PerformSetupMenuAction(int button)
        {
            switch (button)
            {
            case SETUP_MENU_EASY_BUTTON:
                GameController.SetDifficulty(AIOption.Easy);
                break;

            case SETUP_MENU_MEDIUM_BUTTON:
                GameController.SetDifficulty(AIOption.Medium);
                break;

            case SETUP_MENU_HARD_BUTTON:
                GameController.SetDifficulty(AIOption.Hard);
                break;
            }
            //Always end state - handles exit button as well
            GameController.EndCurrentState();
        }
        /// <summary>
        /// The game menu was clicked, perform the button's action.
        /// </summary>
        /// <param name="button">the button pressed</param>
        private static void PerformGameMenuAction(int button)
        {
            switch (button)
            {
            case GAME_MENU_RETURN_BUTTON:
                GameController.EndCurrentState();
                break;

            case GAME_MENU_SURRENDER_BUTTON:
                GameController.EndCurrentState();
                //end game menu
                GameController.EndCurrentState();
                //end game
                break;

            case GAME_MENU_QUIT_BUTTON:
                GameController.AddNewState(GameState.Quitting);
                break;
            }
        }
        /// <summary>
        /// The main menu was clicked, perform the button's action.
        /// </summary>
        /// <param name="button">the button pressed</param>
        private static void PerformMainMenuAction(int button)
        {
            switch (button)
            {
            case MAIN_MENU_PLAY_BUTTON:
                GameController.StartGame();
                break;

            case MAIN_MENU_SETUP_BUTTON:
                GameController.AddNewState(GameState.AlteringSettings);
                break;

            case MAIN_MENU_TOP_SCORES_BUTTON:
                GameController.AddNewState(GameState.ViewingHighScores);
                break;

            case MAIN_MENU_QUIT_BUTTON:
                GameController.EndCurrentState();
                break;
            }
        }
        public static void HandleVolumeMenuInput(int primaryMenu)
        {
            if (SwinGame.KeyTyped(KeyCode.EscapeKey))
            {
                GameController.EndCurrentState();
                return;
            }
            else if (SwinGame.MouseClicked(MouseButton.LeftButton))
            {
                if (UtilityFunctions.IsMouseInRectangle(VOLUME_BUTTON_X, VOLUME_BUTTON_Y, VOLUME_BUTTON_SIZE, VOLUME_BUTTON_SIZE))
                {
                    // Plus button
                    UtilityFunctions.VolumeLevel += 0.1f;
                    Audio.SetMusicVolume(UtilityFunctions.VolumeLevel);
                }
                else if (UtilityFunctions.IsMouseInRectangle(VOLUME_BUTTON_X + VOLUME_BUTTON_SIZE + VOLUME_BUTTON_GAP,
                                                             VOLUME_BUTTON_Y, VOLUME_BUTTON_SIZE, VOLUME_BUTTON_SIZE))
                {
                    // Minus button
                    UtilityFunctions.VolumeLevel -= 0.1f;
                    Audio.SetMusicVolume(UtilityFunctions.VolumeLevel);
                }
                else
                {
                    // None clicked, so exit menu
                    GameController.EndCurrentState();
                    // And handle any clicks for primary menu
                    if (primaryMenu == MAIN_MENU)
                    {
                        HandleMainMenuInput();
                    }
                    else if (primaryMenu == GAME_MENU)
                    {
                        HandleGameMenuInput();
                    }
                }
            }

            //return false;
        }
 // '' <summary>
 // '' End the current state and add in the new state.
 // '' </summary>
 // '' <param name="newState">the new state of the game</param>
 public static void SwitchState(GameState newState)
 {
     GameController.EndCurrentState();
     GameController.AddNewState(newState);
 }