/// <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;
            var loopTo = _Scores.Count - 1;

            for (i = 0; i <= loopTo; 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.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);
                }
            }
        }
 /// <summary>
 /// Draws the message to the screen
 /// </summary>
 public static void DrawMessage()
 {
     SwinGame.DrawText(Message, MESSAGE_COLOR, GameResources.GameFont("Courier"), FIELD_LEFT, MESSAGE_TOP);
 }
示例#3
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)
        {
            int btnTop;
            var toDraw = default(Rectangle);

            btnTop = MENU_TOP - (MENU_GAP + BUTTON_HEIGHT) * level;
            int i;
            var loopTo = _menuStructure[menu].Length - 1;

            for (i = 0; i <= loopTo; i++)
            {
                int btnLeft;
                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);
                }
            }
        }
示例#4
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.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.DrawDestroyedShips(GameController.HumanPlayer);
            UtilityFunctions.DrawDestroyedShips(GameController.ComputerPlayer);
            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);
            UtilityFunctions.DrawAxis();
        }