Esempio n. 1
0
        /// <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      = 35;
            const int SCORE_TAB      = 150;

            if (_Scores.Count == 0)
            {
                LoadScores();
            }

            SwinGame.DrawText("   High Scores   ", Color.White, GameResources.GameFont("Arial40"), SCORES_LEFT, SCORES_HEADING);

            //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, Color.White, GameResources.GameFont("Arial"), SCORES_LEFT, SCORES_TOP + i * SCORE_GAP);
                    SwinGame.DrawText(" " + s.Value, Color.White, GameResources.GameFont("Arial"), SCORES_LEFT + SCORE_TAB, SCORES_TOP + i * SCORE_GAP);
                }
                else
                {
                    SwinGame.DrawText(i + 1 + ":  " + s.Name, Color.White, GameResources.GameFont("Arial"), SCORES_LEFT, SCORES_TOP + i * SCORE_GAP);
                    SwinGame.DrawText(" " + s.Value, Color.White, GameResources.GameFont("Arial"), SCORES_LEFT + SCORE_TAB, SCORES_TOP + i * SCORE_GAP);
                }
            }
        }
Esempio n. 2
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 = 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(Color.White, 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 (_menuStructure[menu][i] == _menuStructure[1][0]) {
 *                                      SwinGame.DrawTextLines(_menuStructure[1][0], MENU_COLOR, Color.Peru, GameResources.GameFont("Menu"), FontAlignment.AlignCenter, btnLeft + TEXT_OFFSET, btnTop + TEXT_OFFSET, BUTTON_WIDTH, BUTTON_HEIGHT);
 *                              }
 *                              else if (_menuStructure[menu][i] == _menuStructure[1][1]) {
 *                                      SwinGame.DrawTextLines(_menuStructure[1][1], MENU_COLOR, Color.Orange, GameResources.GameFont("Menu"), FontAlignment.AlignCenter, btnLeft + TEXT_OFFSET, btnTop + TEXT_OFFSET, BUTTON_WIDTH, BUTTON_HEIGHT);
 *                              }
 *                              else if (_menuStructure[menu][i] == _menuStructure[1][2]) {
 *                                      SwinGame.DrawTextLines(_menuStructure[1][2], MENU_COLOR, Color.Orange, GameResources.GameFont("Menu"), FontAlignment.AlignCenter, btnLeft + TEXT_OFFSET, btnTop + TEXT_OFFSET, BUTTON_WIDTH, BUTTON_HEIGHT);
 *                              } //this code changes the colour of the textbox -> seek dirrent location or code
 */
                if (SwinGame.MouseDown(MouseButton.LeftButton) & IsMouseOverMenu(i, level, xOffset))
                {
                    SwinGame.DrawRectangle(HIGHLIGHT_COLOR, btnLeft, btnTop, BUTTON_WIDTH, BUTTON_HEIGHT);
                }
            }
        }
Esempio n. 3
0
        /// <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'RE FLEET HAS SUNK", Color.Crimson, Color.Transparent, GameResources.GameFont("MenuLarge"), FontAlignment.AlignCenter, 0, 250, SwinGame.ScreenWidth(), SwinGame.ScreenHeight());
            }
            else
            {
                SwinGame.DrawTextLines("THERE FLEET HAS SUNK", Color.Gold, Color.Transparent, GameResources.GameFont("MenuLarge"), FontAlignment.AlignCenter, 0, 250, SwinGame.ScreenWidth(), SwinGame.ScreenHeight());
            }
        }
Esempio n. 4
0
 /// <summary>
 /// Draws the message to the screen
 /// </summary>
 public static void DrawMessage()
 {
     SwinGame.DrawText(Message, MESSAGE_COLOR, GameResources.GameFont("Courier"), FIELD_LEFT, MESSAGE_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());
            }
        }
Esempio n. 6
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.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>
        /// 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(Color.White, 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);
                }
            }
        }
Esempio n. 8
0
        // Summary: Draws the game during the attack phase.
        // Remarks: Isuru -  Updated keycodes
        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 BACK_BUTTON_LEFT   = 710;
            const int BACK_BUTTON_TOP    = 5;
            const int BACK_BUTTON_WIDTH  = 60;
            const int TOP_BUTTONS_HEIGHT = 46;



            //sets parameter to true if the player presses key combination of Shift + C
            if ((SwinGame.KeyDown(KeyCode.vk_RSHIFT) | SwinGame.KeyDown(KeyCode.vk_LSHIFT)) & SwinGame.KeyDown(KeyCode.vk_c))
            {
                UtilityFunctions.DrawField(GameController.HumanPlayer.EnemyGrid, GameController.ComputerPlayer, true, false);
            }
            else
            {
                UtilityFunctions.DrawField(GameController.HumanPlayer.EnemyGrid, GameController.ComputerPlayer, true, true);
            }

            if (UtilityFunctions.IsMouseInRectangle(BACK_BUTTON_LEFT, BACK_BUTTON_TOP, BACK_BUTTON_WIDTH, TOP_BUTTONS_HEIGHT) && SwinGame.MouseClicked(MouseButton.LeftButton))
            {
                GameController.AddNewState(GameState.ViewingGameMenu);
            }

            UtilityFunctions.DrawSmallField(GameController.HumanPlayer.PlayerGrid, GameController.HumanPlayer);
            UtilityFunctions.DrawMessage();

            SwinGame.DrawBitmap(GameResources.GameImage("Back"), BACK_BUTTON_LEFT, BACK_BUTTON_TOP);

            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);
        }
Esempio n. 9
0
        // Draws the menu at the indicated level.
        // Parameter: menu - The menu to draw
        // Parameter: level - The level (height) of the menu
        // Parameter: xOffset - The offset of the menu
        // 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.
        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(Color.White, btnLeft, btnTop, BUTTON_WIDTH, BUTTON_HEIGHT)
                Rectangle drawRect = new Rectangle();
                drawRect.X      = btnLeft + TEXT_OFFSET;
                drawRect.Y      = btnTop + TEXT_OFFSET;
                drawRect.Width  = BUTTON_WIDTH;
                drawRect.Height = BUTTON_HEIGHT;
                SwinGame.DrawTextLines(_menuStructure [menu] [i], MENU_COLOR, Color.Black, GameResources.GameFont("Menu"), FontAlignment.AlignCenter, drawRect);
                //SwinGame.DrawTextLines(_menuStructure[menu][i], MENU_COLOR, Color.Black, GameResources.GameFont("Menu"), FontAlignment.AlignCenter, btnLeft + TEXT_OFFSET, btnTop + TEXT_OFFSET, BUTTON_WIDTH, BUTTON_HEIGHT);


                //hover on menu item changes to white
                if (SwinGame.MouseX() > btnLeft && SwinGame.MouseY() > btnTop && SwinGame.MouseX() < (btnLeft + BUTTON_WIDTH) && SwinGame.MouseY() < (btnTop + BUTTON_HEIGHT))
                {
                    SwinGame.DrawTextLines(_menuStructure[menu][i], Color.White, Color.Black, GameResources.GameFont("Menu"), FontAlignment.AlignCenter, drawRect);
                }

                if (SwinGame.MouseDown(MouseButton.LeftButton) & IsMouseOverMenu(i, level, xOffset))
                {
                    SwinGame.DrawRectangle(HIGHLIGHT_COLOR, btnLeft, btnTop, BUTTON_WIDTH, BUTTON_HEIGHT);
                }
            }
        }