/// <summary> /// Read the user's name for their highscore. /// <param name="value">the player's score.</param> /// <remarks>This verifies if the score is a highscore.</remarks> /// </summary> public static void ReadHighScore(int value) { const int ENTRY_TOP = 500; if (_Scores.Count == 0) { LoadScores(); } // is it a highscore 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: "); Rectangle nameEntryArea = new Rectangle { X = x, Y = ENTRY_TOP, Width = 20, Height = 10 }; SwinGame.StartReadingText(Color.White, NAME_WIDTH, GameResources.GameFont("Courier"), nameEntryArea); // Read the text from the user while (SwinGame.ReadingText()) { SwinGame.ProcessEvents(); UtilityFunctions.DrawBackground(); Console.WriteLine("loaded"); DrawHighScores(); SwinGame.DrawText("Name: ", Color.White, GameResources.GameFont("Courier"), SCORES_LEFT, ENTRY_TOP); SwinGame.RefreshScreen(60); } s.Name = SwinGame.TextReadAsASCII(); if (s.Name.Length < 3) { s.Name = s.Name + new string(' ', 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 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.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(); }
/// <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, 4 * 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(); SaveScores(); GameController.EndCurrentState(); } }
/// <summary> /// Draws the current state of the game to the screen. /// <remarks> /// What is drawn depends upon the state of the game. /// </remarks> /// </summary> 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.Rules: { MenuController.drawRules(); break; } case GameState.Controls: { MenuController.drawControls(); break; } case GameState.AlteringVolume: { if (_state.Skip(1).First() == GameState.ViewingGameMenu) { MenuController.DrawVolumeSettings(1); } else if (_state.Skip(1).First() == GameState.ViewingMainMenu) { MenuController.DrawVolumeSettings(0); } 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(60); }