// '' <summary> // '' Draws the high scores to the screen. // '' </summary> public static void DrawHighScores() { const int SCORES_HEADING = 200; const int SCORES_TOP = 250; const int SCORE_GAP = 30; if ((_Scores.Count == 0)) { HighScoreController.LoadScores(); } SwinGame.DrawText(" High Scores ", Color.Black, GameResources.GameFont("Courier"), SCORES_LEFT, SCORES_HEADING); // For all of the scores int i; for (i = 0; (i <= (_Scores.Count - 1)); i++) { Score s; s = _Scores[i]; // for scores 1 - 9 use 01 - 09 if ((i < 9)) { SwinGame.DrawText((" " + ((i + 1) + (": " + (s.Name + (" " + s.Value))))), Color.Black, GameResources.GameFont("Courier"), SCORES_LEFT, (SCORES_TOP + (i * SCORE_GAP))); } else { SwinGame.DrawText(((i + 1) + (": " + (s.Name + (" " + s.Value)))), Color.Black, GameResources.GameFont("Courier"), SCORES_LEFT, (SCORES_TOP + (i * SCORE_GAP))); } } }
/// <summary> /// Draw the end of the game screen, shows the win/lose state /// </summary> public static void DrawEndOfGame() { Rectangle toDraw = new Rectangle(); string whatShouldIPrint = null; UtilityFunctions.DrawField(GameController.ComputerPlayer.PlayerGrid, GameController.ComputerPlayer, true); UtilityFunctions.DrawSmallField(GameController.HumanPlayer.PlayerGrid, GameController.HumanPlayer); toDraw.X = 0; toDraw.Y = 250; toDraw.Width = SwinGame.ScreenWidth(); toDraw.Height = SwinGame.ScreenHeight(); if (GameController.HumanPlayer.IsDestroyed) { whatShouldIPrint = "YOU LOSE!"; } else { whatShouldIPrint = "-- WINNER --"; } SwinGame.DrawTextLines(whatShouldIPrint, Color.White, Color.Transparent, GameResources.GameFont("ArialLarge"), FontAlignment.AlignCenter, toDraw); }
/// <summary> /// Draws the high scores to the screen. /// </summary> public static void DrawHighScores() { const int SCORES_HEADING = 40; const int SCORES_TOP = 80; const int SCORE_GAP = 30; if (_Scores.Count == 0) { LoadScores(); } SwinGame.DrawText(" High Scores ", Color.White, GameResources.GameFont("Courier"), SCORES_LEFT, SCORES_HEADING); SwinGame.DrawBitmap(GameResources.GameImage("BackToMenu"), MENU_BUTTON_LEFT, MENU_BUTTON_TOP); //For all of the scores int i = 0; for (i = 0; i <= _Scores.Count - 1; i++) { Score s = default(Score); s = _Scores[i]; //for scores 1 - 9 use 01 - 09 if (i < 9) { SwinGame.DrawText(" " + (i + 1) + ": " + s.Name + " " + s.Value, Color.White, GameResources.GameFont("Courier"), SCORES_LEFT, SCORES_TOP + i * SCORE_GAP); } else { SwinGame.DrawText(i + 1 + ": " + s.Name + " " + s.Value, Color.White, GameResources.GameFont("Courier"), SCORES_LEFT, SCORES_TOP + i * SCORE_GAP); } } }
// Draws the high scores onto the screen public static void DrawHighScores() { const int SCORES_HEADING = 40; const int SCORES_TOP = 80; const int SCORE_GAP = 30; if (_Scores.Count == 0) { LoadScores(); } SwinGame.DrawText(" High Scores ", Color.White, GameResources.GameFont("Courier"), SCORES_LEFT, SCORES_HEADING); int i; for (i = 0; i <= _Scores.Count - 1; i++) { Score s; s = _Scores[i]; if (i < 9) { SwinGame.DrawText(" " + (i + 1) + ": " + s.Name + " " + s.Value, Color.White, GameResources.GameFont("Courier"), SCORES_LEFT, SCORES_TOP + i * SCORE_GAP); } else { SwinGame.DrawText(i + 1 + ": " + s.Name + " " + s.Value, Color.White, GameResources.GameFont("Courier"), SCORES_LEFT, SCORES_TOP + i * SCORE_GAP); } } }
public static void DrawMessage() { SwinGame.DrawText(Message, MESSAGE_COLOR, GameResources.GameFont("Courier"), FIELD_LEFT, MESSAGE_TOP); }
/// <summary> /// Draws the game during the attack phase. /// </summary>s public static void DrawDiscovery() { const int SCORES_LEFT = 172; const int SHOTS_TOP = 157; const int HITS_TOP = 206; const int SPLASH_TOP = 256; if ((SwinGame.KeyDown(KeyCode.vk_LSHIFT) || SwinGame.KeyDown(KeyCode.vk_RSHIFT)) && SwinGame.KeyDown(KeyCode.vk_c)) { UtilityFunctions.DrawField(GameController.HumanPlayer.EnemyGrid, GameController.ComputerPlayer, true); } else { UtilityFunctions.DrawField(GameController.HumanPlayer.EnemyGrid, GameController.ComputerPlayer, false); } UtilityFunctions.DrawSmallField(GameController.HumanPlayer.PlayerGrid, GameController.HumanPlayer); UtilityFunctions.DrawMessage(); SwinGame.DrawText(GameController.HumanPlayer.Shots.ToString(), Color.White, GameResources.GameFont("Menu"), SCORES_LEFT, SHOTS_TOP); SwinGame.DrawText(GameController.HumanPlayer.Hits.ToString(), Color.White, GameResources.GameFont("Menu"), SCORES_LEFT, HITS_TOP); SwinGame.DrawText(GameController.HumanPlayer.Missed.ToString(), Color.White, GameResources.GameFont("Menu"), SCORES_LEFT, SPLASH_TOP); //SwinGame.DrawBitmap(GameResources.GameImage("MenuButton"), MENU_LEFT, MENU_TOP); if (Sound == true) { SwinGame.DrawText("AUDIO ON", Color.White, MUTE_BUTTON_LEFT, MUTE_BUTTON_TOP); } if (Sound == false) { SwinGame.DrawText("AUDIO OFF", Color.Grey, MUTE_BUTTON_LEFT, MUTE_BUTTON_TOP); } }
// '' <summary> // '' Draws the menu at the indicated level. // '' </summary> // '' <param name="menu">the menu to draw</param> // '' <param name="level">the level (height) of the menu</param> // '' <param name="xOffset">the offset of the menu</param> // '' <remarks> // '' The menu text comes from the _menuStructure field. The level indicates the height // '' of the menu, to enable sub menus. The xOffset repositions the menu horizontally // '' to allow the submenus to be positioned correctly. // '' </remarks> private static void DrawButtons(int menu, int level, int xOffset) { int btnTop; Rectangle toDraw = new Rectangle(); btnTop = (MENU_TOP - ((MENU_GAP + BUTTON_HEIGHT) * level)); int i; for (i = 0; (i <= (_menuStructure[menu].Length - 1)); i++) { int btnLeft; btnLeft = (MENU_LEFT + (BUTTON_SEP * (i + xOffset))); toDraw.X = (btnLeft + TEXT_OFFSET); toDraw.Y = (btnTop + TEXT_OFFSET); toDraw.Width = BUTTON_WIDTH; toDraw.Height = BUTTON_HEIGHT; SwinGame.DrawText(_menuStructure[menu][i], MENU_COLOR, SwinGame.RGBColor(86, 111, 131), GameResources.GameFont("Menu"), FontAlignment.AlignCenter, toDraw); if ((SwinGame.MouseDown(MouseButton.LeftButton) && MenuController.IsMouseOverMenu(i, level, xOffset))) { SwinGame.DrawRectangle(HIGHLIGHT_COLOR, btnLeft, btnTop, BUTTON_WIDTH, BUTTON_HEIGHT); } } }
/// <summary> /// Draws the high scores to the screen. /// </summary> public static void DrawHighScores() { const int SCORES_HEADING = 40; const int SCORES_TOP = 80; const int SCORE_GAP = 30; if (_Scores.Count == 0) { LoadScores(); } SwinGame.DrawText(" High Scores ", Color.White, GameResources.GameFont("TopScore"), SCORES_LEFT, SCORES_HEADING); //For all of the scores int i = 0; for (i = 0; i <= _Scores.Count - 1; i++) { Score s = new Score(); s = _Scores[i]; //for scores 1 - 9 use 01 - 09 if (i < 9) { SwinGame.DrawText(" " + System.Convert.ToString(i + 1) + ": " + s.Name + " " + System.Convert.ToString(s.Value), Color.White, GameResources.GameFont("Courier"), SCORES_LEFT, SCORES_TOP + i * SCORE_GAP); } else { SwinGame.DrawText(i + 1 + ": " + s.Name + " " + System.Convert.ToString(s.Value), Color.White, GameResources.GameFont("Courier"), SCORES_LEFT, SCORES_TOP + i * SCORE_GAP); } } }
/// <summary> /// Draws the menu at the indicated level. /// </summary> /// <param name="menu">the menu to draw</param> /// <param name="level">the level (height) of the menu</param> /// <param name="xOffset">the offset of the menu</param> /// <remarks> /// The menu text comes from the _menuStructure field. The level indicates the height /// of the menu, to enable sub menus. The xOffset repositions the menu horizontally /// to allow the submenus to be positioned correctly. /// </remarks> private static void DrawButtons(int menu, int level, int xOffset) { int btnTop = 0; btnTop = MENU_TOP - (MENU_GAP + BUTTON_HEIGHT) * level; int i = 0; for (i = 0; i <= _menuStructure[menu].Length - 1; i++) { int btnLeft = 0; btnLeft = MENU_LEFT + BUTTON_SEP * (i + xOffset); SwinGame.FillRectangle(HIGHLIGHT_COLOR, btnLeft, btnTop, BUTTON_WIDTH, BUTTON_HEIGHT); SwinGame.DrawTextLines(_menuStructure[menu][i], MENU_COLOR, Color.Black, GameResources.GameFont("Menu"), FontAlignment.AlignCenter, btnLeft + TEXT_OFFSET, btnTop + TEXT_OFFSET, BUTTON_WIDTH, BUTTON_HEIGHT); if (SwinGame.MouseDown(MouseButton.LeftButton) & IsMouseOverMenu(i, level, xOffset)) { SwinGame.DrawRectangle(HIGHLIGHT_COLOR, btnLeft, btnTop, BUTTON_WIDTH, BUTTON_HEIGHT); } } }
/// <summary> /// Draws the game during the attack phase. /// </summary>s public static void DrawDiscovery() { const int SCORES_LEFT = 172; const int SHOTS_TOP = 157; const int HITS_TOP = 206; const int SPLASH_TOP = 256; if (((SwinGame.KeyDown(KeyCode.vk_b) || (SwinGame.KeyDown(KeyCode.vk_c)) && SwinGame.KeyDown(KeyCode.vk_d)))) { UtilityFunctions.DrawField(GameController.HumanPlayer.EnemyGrid, GameController.ComputerPlayer, true); } else { UtilityFunctions.DrawField(GameController.HumanPlayer.EnemyGrid, GameController.ComputerPlayer, false); } UtilityFunctions.DrawSmallField(GameController.HumanPlayer.PlayerGrid, GameController.HumanPlayer); UtilityFunctions.DrawMessage(); SwinGame.DrawText(GameController.HumanPlayer.Shots.ToString(), Color.White, GameResources.GameFont("Menu"), SCORES_LEFT, SHOTS_TOP); SwinGame.DrawText(GameController.HumanPlayer.Hits.ToString(), Color.White, GameResources.GameFont("Menu"), SCORES_LEFT, HITS_TOP); SwinGame.DrawText(GameController.HumanPlayer.Missed.ToString(), Color.White, GameResources.GameFont("Menu"), SCORES_LEFT, SPLASH_TOP); }
/// <summary> /// ''' Draw the end of the game screen, shows the win/lose state /// ''' </summary> public static void DrawEndOfGame() { UtilityFunctions.DrawField(GameController.ComputerPlayer.PlayerGrid, GameController.ComputerPlayer, true); UtilityFunctions.DrawSmallField(GameController.HumanPlayer.PlayerGrid, GameController.HumanPlayer); if (GameController.HumanPlayer.IsDestroyed) { SwinGame.DrawTextLines("YOU LOSE!", Color.White, Color.Transparent, GameResources.GameFont("ArialLarge"), FontAlignment.AlignCenter, 0, 250, SwinGame.ScreenWidth(), SwinGame.ScreenHeight()); } else { SwinGame.DrawTextLines("-- WINNER --", Color.White, Color.Transparent, GameResources.GameFont("ArialLarge"), FontAlignment.AlignCenter, 0, 250, SwinGame.ScreenWidth(), SwinGame.ScreenHeight()); } }
// '' <summary> // '' Draws the game during the attack phase. // '' </summary>s public static void DrawDiscovery() { const int SCORES_LEFT = 172; const int SHOTS_TOP = 157; const int HITS_TOP = 206; const int SPLASH_TOP = 256; const int RATIO_TOP = 303; if (((SwinGame.KeyDown(KeyCode.LeftShiftKey) || SwinGame.KeyDown(KeyCode.RightShiftKey)) && SwinGame.KeyDown(KeyCode.CKey))) { UtilityFunctions.DrawField(GameController.HumanPlayer.EnemyGrid, GameController.ComputerPlayer, true); } else { UtilityFunctions.DrawField(GameController.HumanPlayer.EnemyGrid, GameController.ComputerPlayer, false); } UtilityFunctions.DrawSmallField(GameController.HumanPlayer.PlayerGrid, GameController.HumanPlayer); UtilityFunctions.DrawMessage(); SwinGame.DrawText(GameController.HumanPlayer.Shots.ToString(), Color.White, GameResources.GameFont("Ingame_Menu"), SCORES_LEFT, SHOTS_TOP); SwinGame.DrawText(GameController.HumanPlayer.Hits.ToString(), Color.White, GameResources.GameFont("Ingame_Menu"), SCORES_LEFT, HITS_TOP); SwinGame.DrawText(GameController.HumanPlayer.Missed.ToString(), Color.White, GameResources.GameFont("Ingame_Menu"), SCORES_LEFT, SPLASH_TOP); if (GameController.HumanPlayer.Shots != 0) { SwinGame.DrawText((Math.Round(((double)GameController.HumanPlayer.Hits / (double)GameController.HumanPlayer.Shots) * 100, 2)).ToString() + " %", Color.White, GameResources.GameFont("Ingame_Menu"), SCORES_LEFT, RATIO_TOP); } else { SwinGame.DrawText("N/A", Color.White, GameResources.GameFont("Ingame_Menu"), SCORES_LEFT, RATIO_TOP); } }
/// <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(); } bool temp = true; if (_Scores.Count > 0) { if (value < _Scores[_Scores.Count - 1].Value) { temp = false; } } // is it a high score if (temp) { 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); } if (!temp) { _Scores.RemoveAt(_Scores.Count - 1); } _Scores.Add(s); _Scores.Sort(); GameController.EndCurrentState(); } }
/// <summary> /// Draws the high scores to the screen. /// </summary> public static void DrawHighScores() { const int SCORES_HEADING = 40; const int SCORES_TOP = 80; const int SCORE_GAP = 30; if (_Scores.Count == 0) { LoadScores(); } SwinGame.DrawText(" High Scores ", Color.White, GameResources.GameFont("Courier"), SCORES_LEFT, SCORES_HEADING); // For all of the scores int i = default(int); var loopTo = _Scores.Count - 1; for (i = 0; i <= loopTo; i++) { Score s = default(Score); s = _Scores[i]; // for scores 1 - 9 use 01 - 09 if (i < 9) { SwinGame.DrawText(" " + Convert.ToString((i + 1)) + ": " + s.Name + " " + Convert.ToString(s.Value), Color.White, GameResources.GameFont("Courier"), SCORES_LEFT, SCORES_TOP + (i * SCORE_GAP)); } else { SwinGame.DrawText(Convert.ToString(i + 1) + ": " + s.Name + " " + Convert.ToString(s.Value), Color.White, GameResources.GameFont("Courier"), SCORES_LEFT, SCORES_TOP + (i * SCORE_GAP)); } } }
/// <summary> /// Draws the menu at the indicated level. /// </summary> /// <param name="menu">the menu to draw</param> /// <param name="level">the level (height) of the menu</param> /// <param name="xOffset">the offset of the menu</param> /// <remarks> /// The menu text comes from the _menuStructure field. The level indicates the height /// of the menu, to enable sub menus. The xOffset repositions the menu horizontally /// to allow the submenus to be positioned correctly. /// </remarks> private static void DrawButtons(int menu, int level, int xOffset) { int btnTop = 0; Rectangle toDraw = new Rectangle(); btnTop = MENU_TOP - (MENU_GAP + BUTTON_HEIGHT) * level; int i = 0; //INSTANT C# NOTE: The ending condition of VB 'For' loops is tested only on entry to the loop. Instant C# has created a temporary variable in order to use the initial value of _menuStructure(menu).Length for every iteration: int tempVar = _menuStructure[menu].Length; for (i = 0; i < tempVar; i++) { int btnLeft = MENU_LEFT + BUTTON_SEP * (i + xOffset); //SwinGame.FillRectangle(Color.White, btnLeft, btnTop, BUTTON_WIDTH, BUTTON_HEIGHT) toDraw.X = btnLeft + TEXT_OFFSET; toDraw.Y = btnTop + TEXT_OFFSET; toDraw.Width = BUTTON_WIDTH; toDraw.Height = BUTTON_HEIGHT; SwinGame.DrawTextLines(_menuStructure[menu][i], MENU_COLOR, Color.Black, GameResources.GameFont("Menu"), FontAlignment.AlignCenter, toDraw); if ((SwinGame.MouseDown(MouseButton.LeftButton) && !IsMouseOverMenu(i, level, xOffset))) { SwinGame.DrawRectangle(HIGHLIGHT_COLOR, btnLeft, btnTop, BUTTON_WIDTH, BUTTON_HEIGHT); } } }