/*<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) { //used to get the correct area for the highscore input, X's are just used to force spacing Rectangle rec = new Rectangle(); rec.X = SCORES_LEFT + SwinGame.TextWidth(GameResources.GameFont("Courier"), "Name:"); rec.Y = ENTRY_TOP; rec.Height = SwinGame.TextHeight(GameResources.GameFont("Courier"), "XXX"); rec.Width = SwinGame.TextWidth(GameResources.GameFont("Courier"), "XXXXXXXXXXXXXX"); Score s = new Score(); s.Value = value; GameController.AddNewState(GameState.ViewingHighScores); SwinGame.StartReadingText(Color.White, NAME_WIDTH, GameResources.GameFont("Courier"), rec); //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(); } //convert the inputted string to ascii and to uppercase s.Name = SwinGame.TextReadAsASCII().ToUpper(); if (s.Name.Length < 3) { s.Name = s.Name + new string(Convert.ToChar(" "), 3 - s.Name.Length); } s.Length = s.Name.Length; _Scores.RemoveAt(_Scores.Count - 1); _Scores.Add(s); _Scores.Sort(); SaveScores(); GameController.EndCurrentState(); } }
/// <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 = 0; 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(Convert.ToChar(" "), 3 - s.Name.Length); } _Scores.RemoveAt(_Scores.Count - 1); _Scores.Add(s); _Scores.Sort(); GameController.EndCurrentState(); } }
/// <summary> /// Draws the current state of the game to the screen. /// </summary> /// <remarks> /// What is drawn depends upon the state of the game. /// </remarks> public void DrawScreen() { _utility.DrawBackground(this); switch (CurrentState) { case GameState.ViewingMainMenu: _menu.DrawMainMenu(this); break; case GameState.ViewingGameMenu: _menu.DrawGameMenu(this); break; case GameState.AlteringSettings: _menu.DrawSettings(this); break; case GameState.Deploying: _deployment.DrawDeployment(this); _highScore.DrawHighScore(_resources); _menu.DrawSetting(this); DrawAIdifficulty(); break; case GameState.Discovering: _discovery.DrawDiscovery(this); _highScore.DrawHighScore(_resources); DrawAIdifficulty(); break; case GameState.EndingGame: _endGame.DrawEndOfGame(this); break; case GameState.ViewingHighScores: _highScore.DrawHighScores(this); break; } _utility.DrawAnimations(); SwinGame.RefreshScreen(); }
/*<summary> * Draws the current state of the game to the screen. *</summary> *<remarks> * What is drawn depends upon the state of the game. *</remarks> */ public static void DrawScreen() { UtilityFunctions.DrawBackground(); switch (CurrentState) { case GameState.ViewingMainMenu: MenuController.DrawMainMenu(); break; case GameState.ViewingGameMenu: MenuController.DrawGameMenu(); break; case GameState.AlteringSettings: MenuController.DrawSettings(); break; case GameState.AlteringShips: MenuController.DrawShipsMenu(); break; case GameState.Deploying: DeploymentController.DrawDeployment(); break; case GameState.Discovering: DiscoveryController.DrawDiscovery(); break; case GameState.EndingGame: EndingGameController.DrawEndOfGame(); break; case GameState.ViewingHighScores: HighScoreController.DrawHighScores(); break; } UtilityFunctions.DrawAnimations(); SwinGame.RefreshScreen(); }