private static void PerformGameMenuAction(int button) { // CHECK Implement Case Statement switch (button) { case GAME_MENU_RETURN_BUTTON: GameController.EndCurrentState(); break; case GAME_MENU_SURRENDER_BUTTON: GameController.EndCurrentState(); GameController.EndCurrentState(); break; case GAME_MENU_QUIT_BUTTON: GameController.AddNewState(GameState.QuitConfirm); break; } }
// '' <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(); }
// If the setup menu was clicked, perform the button's action private static void PerformSetupMenuAction(int button) { // CHECK Implement Case Statement 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; } 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> // '' 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 = 550; if ((_Scores.Count == 0)) { HighScoreController.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.Black, NAME_WIDTH, GameResources.GameFont("Courier"), x, ENTRY_TOP); // Read the text from the user while (SwinGame.ReadingText()) { SwinGame.ProcessEvents(); UtilityFunctions.DrawBackground(); HighScoreController.DrawHighScores(); SwinGame.DrawText("Name: ", Color.Black, GameResources.GameFont("Courier"), SCORES_LEFT, ENTRY_TOP); SwinGame.RefreshScreen(); } s.Name = SwinGame.TextReadAsASCII(); if ((s.Name.Length < 3)) { s.Name = (s.Name + new string(((char)(' ')), (3 - s.Name.Length))); } _Scores.RemoveAt((_Scores.Count - 1)); _Scores.Add(s); _Scores.Sort(); SaveScores(); GameController.EndCurrentState(); } }
// '' <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; } }
// Reads the users name for their high score public static void ReadHighScore(int value) { const int ENTRY_TOP = 500; if (_Scores.Count == 0) { LoadScores(); } 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(SwinGame.FontNamed("Courier"), "Name: "); SwinGame.StartReadingText(Color.White, NAME_WIDTH, GameResources.GameFont("Courier"), x, ENTRY_TOP); 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(Convert.ToChar(" "), 3 - s.Name.Length); } _Scores.RemoveAt(_Scores.Count - 1); _Scores.Add(s); _Scores.Sort(); SaveScores(); GameController.EndCurrentState(); } }
// '' <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); }
private static void PerformShipMenuAction(int button) { GameController.SetShips(button + 1); GameController.EndCurrentState(); }