/// <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.GetFont("Courier"), SCORES_LEFT, SCORES_HEADING);

            // For all of the scores
            for (int i = 0; i < _scores.Count; 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.White, GameResources.GetFont("Courier"), SCORES_LEFT, SCORES_TOP + i * SCORE_GAP);
                }
                else
                {
                    SwinGame.DrawText(i + 1 + ":   " + s.name + "   " + s.value, Color.White, GameResources.GetFont("Courier"), SCORES_LEFT, SCORES_TOP + i * SCORE_GAP);
                }
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Draw the end of the game screen, shows the win/lose state
        /// </summary>
        public static void DrawEndOfGame()
        {
            Rectangle toDraw = new Rectangle {
                X      = 0,
                Y      = 250,
                Width  = SwinGame.ScreenWidth(),
                Height = SwinGame.ScreenHeight()
            };

            UtilityFunctions.DrawField(GameController.ComputerPlayer.PlayerGrid, GameController.ComputerPlayer, true);
            UtilityFunctions.DrawSmallField(GameController.HumanPlayer.PlayerGrid, GameController.HumanPlayer);

            string message = (GameController.HumanPlayer.IsDestroyed) ? "You Lose!" : "-- You Win --";

            SwinGame.DrawText(message, Color.White, Color.Transparent, GameResources.GetFont("ArialLarge"), FontAlignment.AlignCenter, toDraw);
        }
        /// <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();
            }

            // Return if this score is not a highscore
            if (_scores.Count > 0 && value <= _scores[_scores.Count - 1].value)
            {
                return;
            }

            Score s = new Score {
                value = value
            };

            int x = SCORES_LEFT + SwinGame.TextWidth(GameResources.GetFont("Courier"), "Name: ");

            GameController.AddNewState(GameState.ViewingHighScores);
            SwinGame.StartReadingText(Color.White, NAME_WIDTH, GameResources.GetFont("Courier"), x, ENTRY_TOP);

            // Reads the text from the user
            while (SwinGame.ReadingText())
            {
                SwinGame.ProcessEvents();
                UtilityFunctions.DrawBackground();
                DrawHighScores();
                SwinGame.DrawText("Name: ", Color.White, GameResources.GetFont("Courier"), SCORES_LEFT, ENTRY_TOP);
                SwinGame.RefreshScreen();
            }

            s.name = SwinGame.TextReadAsASCII();

            if (s.name.Length < 3)
            {
                s.name += new string(Convert.ToChar(' '), 3 - s.name.Length);
            }

            //scores.RemoveAt(scores.Count - 1);
            _scores.Add(s);
            _scores.Sort();
            GameController.EndCurrentState();
        }
Exemplo n.º 4
0
        /// <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)
        {
            Rectangle toDraw = default(Rectangle);
            int       btnTop = MENU_TOP - (MENU_GAP + BUTTON_HEIGHT) * level;

            for (int i = 0; i < _menuStructure[menu].Length; 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, Color.Black, GameResources.GetFont("Menu"), FontAlignment.AlignCenter, toDraw);
                if (SwinGame.MouseDown(MouseButton.LeftButton) & IsMouseOverMenu(i, level, xOffset))
                {
                    SwinGame.DrawRectangle(HIGHLIGHT_COLOR, btnLeft, btnTop, BUTTON_WIDTH, BUTTON_HEIGHT);
                }
            }
        }
Exemplo n.º 5
0
        /// <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.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.GetFont("Menu"), SCORES_LEFT, SHOTS_TOP);
            SwinGame.DrawText(GameController.HumanPlayer.Hits.ToString(), Color.White, GameResources.GetFont("Menu"), SCORES_LEFT, HITS_TOP);
            SwinGame.DrawText(GameController.HumanPlayer.Missed.ToString(), Color.White, GameResources.GetFont("Menu"), SCORES_LEFT, SPLASH_TOP);
        }
Exemplo n.º 6
0
 /// <summary>
 /// Draws the Game menu to the screen
 /// </summary>
 public static void DrawGameMenu()
 {
     // Clears the Screen to Black
     SwinGame.DrawText("Paused", Color.White, GameResources.GetFont("ArialLarge"), 50, 50);
     DrawButtons(GAME_MENU);
 }
Exemplo n.º 7
0
 /// <summary>
 /// Draws the main menu to the screen.
 /// </summary>
 public static void DrawMainMenu()
 {
     // Clears the Screen to Black
     SwinGame.DrawText("Main Menu", Color.White, GameResources.GetFont("ArialLarge"), 50, 50);
     DrawButtons(MAIN_MENU);
 }
Exemplo n.º 8
0
 /// <summary>
 /// Draws the message to the screen
 /// </summary>
 public static void DrawMessage()
 {
     SwinGame.DrawText(Message, MESSAGE_COLOR, GameResources.GetFont("Courier"), FIELD_LEFT, MESSAGE_TOP);
 }