/// <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.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; case MAIN_MENU_AUDIO_BUTTON: GameController.VolAdjust(); break; } }
/// <summary> /// ''' Handles input during the discovery phase of the game. /// ''' </summary> /// ''' <remarks> /// ''' Escape opens the game menu. Clicking the mouse will /// ''' attack a location. /// ''' </remarks> public static void HandleDiscoveryInput() { if (SwinGame.KeyTyped(KeyCode.EscapeKey)) { GameController.AddNewState(GameState.ViewingGameMenu); } if (SwinGame.MouseClicked(MouseButton.LeftButton)) { DoAttack(); } }
// '' <summary> // '' Handles user input for the Deployment phase of the game. // '' </summary> // '' <remarks> // '' Involves selecting the ships, deloying ships, changing the direction // '' of the ships to add, randomising deployment, end then ending // '' deployment // '' </remarks> public static void HandleDeploymentInput() { if (SwinGame.KeyTyped(KeyCode.vk_ESCAPE)) { GameController.AddNewState(GameState.ViewingGameMenu); } if ((SwinGame.KeyTyped(KeyCode.vk_UP) || SwinGame.KeyTyped(KeyCode.vk_DOWN))) { _currentDirection = Direction.UpDown; } if ((SwinGame.KeyTyped(KeyCode.vk_LEFT) || SwinGame.KeyTyped(KeyCode.vk_RIGHT))) { _currentDirection = Direction.LeftRight; } if (SwinGame.KeyTyped(KeyCode.vk_r)) { GameController.HumanPlayer.RandomizeDeployment(); } if (SwinGame.MouseClicked(MouseButton.LeftButton)) { ShipName selected; selected = GetShipMouseIsOver(); if ((selected != ShipName.None)) { _selectedShip = selected; } else { DoDeployClick(); } if ((GameController.HumanPlayer.ReadyToDeploy && UtilityFunctions.IsMouseInRectangle(PLAY_BUTTON_LEFT, TOP_BUTTONS_TOP, PLAY_BUTTON_WIDTH, TOP_BUTTONS_HEIGHT))) { GameController.EndDeployment(); } else if (UtilityFunctions.IsMouseInRectangle(UP_DOWN_BUTTON_LEFT, TOP_BUTTONS_TOP, DIR_BUTTONS_WIDTH, TOP_BUTTONS_HEIGHT)) { _currentDirection = Direction.UpDown; } else if (UtilityFunctions.IsMouseInRectangle(LEFT_RIGHT_BUTTON_LEFT, TOP_BUTTONS_TOP, DIR_BUTTONS_WIDTH, TOP_BUTTONS_HEIGHT)) { _currentDirection = Direction.LeftRight; } else if (UtilityFunctions.IsMouseInRectangle(RANDOM_BUTTON_LEFT, TOP_BUTTONS_TOP, RANDOM_BUTTON_WIDTH, TOP_BUTTONS_HEIGHT)) { GameController.HumanPlayer.RandomizeDeployment(); } } }
/// <summary> /// ''' Read the user's name for their highsSwinGame. /// ''' </summary> /// ''' <param name="value">the player's sSwinGame.</param> /// ''' <remarks> /// ''' This verifies if the score is a highsSwinGame. /// ''' </remarks> public static void ReadHighScore(int value) { const int ENTRY_TOP = 500; if (_Scores.Count == 0) { LoadScores(); } // is it a high score if (value > _Scores[_Scores.Count - 1].Value) { Score s = new Score(); s.Value = value; GameController.AddNewState(GameState.ViewingHighScores); int x; x = SCORES_LEFT + SwinGame.TextWidth(GameResources.GameFont("Courier"), "Name: "); SwinGame.StartReadingText(Color.White, NAME_WIDTH, GameResources.GameFont("Courier"), x, ENTRY_TOP); // Read the text from the user while (SwinGame.ReadingText()) { SwinGame.ProcessEvents(); UtilityFunctions.DrawBackground(); DrawHighScores(); SwinGame.DrawText("Name: ", Color.White, GameResources.GameFont("Courier"), SCORES_LEFT, ENTRY_TOP); SwinGame.RefreshScreen(); } s.Name = SwinGame.TextReadAsASCII(); if (s.Name.Length < 3) { s.Name = s.Name + new string(System.Convert.ToChar(" "), 3 - s.Name.Length); } _Scores.RemoveAt(_Scores.Count - 1); _Scores.Add(s); _Scores.Sort(); 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; } } }