Ejemplo n.º 1
0
        /// <summary>
        /// Draw the end of the game screen, shows the win/lose state
        /// </summary>
        public static void DrawEndOfGame()
        {
            Rectangle toDraw = new Rectangle();
            string    whatShouldIPrint;

            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.DrawText(whatShouldIPrint, Color.White, Color.Transparent, GameResources.GameFont("ArialLarge"), FontAlignment.AlignCenter, toDraw);
        }
Ejemplo n.º 2
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      = 30;

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

            SwinGame.DrawText("   High Scores   ", Color.White, GameResources.GameFont("Square14"), 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(" " + (i + 1) + ":   " + s.Name + "   " + s.Value, Color.White, GameResources.GameFont("Square14"), SCORES_LEFT, SCORES_TOP + i * SCORE_GAP);
                }
                else
                {
                    SwinGame.DrawText(i + 1 + ":   " + s.Name + "   " + s.Value, Color.White, GameResources.GameFont("Square14"), SCORES_LEFT, SCORES_TOP + i * SCORE_GAP);
                }
            }
        }
Ejemplo n.º 3
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;
            const int MENU_BUTTON_TOP  = 72;
            const int MENU_BUTTON_LEFT = 693;

            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);
            }

            SwinGame.DrawBitmap(GameResources.GameImage("MenuButton"), MENU_BUTTON_LEFT, MENU_BUTTON_TOP);


            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);
        }
Ejemplo n.º 4
0
 /// <summary>
 /// Draws the message to the screen
 /// </summary>
 public static void DrawMessage()
 {
     SwinGame.DrawText(Message, MESSAGE_COLOR, GameResources.GameFont("Square14"), FIELD_LEFT, MESSAGE_TOP);
 }
Ejemplo n.º 5
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 (SwinGame.MouseDown(MouseButton.LeftButton) & IsMouseOverMenu(i, level, xOffset))
                {
                    SwinGame.DrawRectangle(HIGHLIGHT_COLOR, btnLeft, btnTop, BUTTON_WIDTH, BUTTON_HEIGHT);
                }
            }
        }
Ejemplo n.º 6
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 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());
            }
        }
Ejemplo n.º 7
0
        /// <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.StartReadingTextWithText("Maximum 15 char", 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 < 15)
                {
                    s.Name = s.Name + new string(Convert.ToChar(" "), 15 - s.Name.Length);
                }


                _Scores.RemoveAt(_Scores.Count - 1);
                _Scores.Add(s);
                _Scores.Sort();
                SaveScores();
                GameController.EndCurrentState();
            }
        }
Ejemplo n.º 8
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      = 30;

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

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

            //New 'Back' button to make the usability of the screen better
            SwinGame.DrawText("Click or press 'Enter' to return to the Main Menu...", Color.White, GameResources.GameFont("Courier"), SCORES_LEFT / 2, SCORES_TOP + 10 * SCORE_GAP);
            SwinGame.DrawBitmap(GameResources.GameImage("Return"), 2 * SCORES_LEFT / 3, SCORES_TOP + 12 * SCORE_GAP);

            //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);
                }
            }
        }
Ejemplo n.º 9
0
        /// <summary>
        /// Draws the game during the attack phase.
        /// </summary>
        /// <remarks>
        /// Isuru: Updated keycodes
        /// </remarks>
        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.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);
        }
Ejemplo n.º 10
0
        public static void DrawHotkeysMenu()
        {
            SwinGame.DrawText("Hover over the keybinding to edit", Color.AntiqueWhite, GameResources.GameFont("Menu"), SwinGame.ScreenWidth() - 550, 25);
            SwinGame.DrawText("Function", Color.AntiqueWhite, GameResources.GameFont("Menu"), SwinGame.ScreenWidth() - HOTKEYS_FUNC, 75);
            SwinGame.DrawText("Key Bound", Color.AntiqueWhite, GameResources.GameFont("Menu"), SwinGame.ScreenWidth() - HOTKEYS_BIND, 75);

            // Escape key
            SwinGame.DrawText("Escape key", Color.AntiqueWhite, SwinGame.ScreenWidth() - HOTKEYS_FUNC, 100);
            SwinGame.DrawText(UtilityFunctions.EscapeKey.ToString(), Color.White, SwinGame.ScreenWidth() - HOTKEYS_BIND, 100);
            // Up key
            SwinGame.DrawText("Up key", Color.AntiqueWhite, SwinGame.ScreenWidth() - HOTKEYS_FUNC, 150);
            SwinGame.DrawText(UtilityFunctions.UpKey.ToString(), Color.White, SwinGame.ScreenWidth() - HOTKEYS_BIND, 150);
            // Down key
            SwinGame.DrawText("Down key", Color.AntiqueWhite, SwinGame.ScreenWidth() - HOTKEYS_FUNC, 200);
            SwinGame.DrawText(UtilityFunctions.DownKey.ToString(), Color.White, SwinGame.ScreenWidth() - HOTKEYS_BIND, 200);
            // Left key
            SwinGame.DrawText("Left key", Color.AntiqueWhite, SwinGame.ScreenWidth() - HOTKEYS_FUNC, 250);
            SwinGame.DrawText(UtilityFunctions.LeftKey.ToString(), Color.White, SwinGame.ScreenWidth() - HOTKEYS_BIND, 250);
            // Random key
            SwinGame.DrawText("Random key", Color.AntiqueWhite, SwinGame.ScreenWidth() - HOTKEYS_FUNC, 300);
            SwinGame.DrawText(UtilityFunctions.RandomKey.ToString(), Color.White, SwinGame.ScreenWidth() - HOTKEYS_BIND, 300);
            // Blue key
            SwinGame.DrawText("Blue key", Color.AntiqueWhite, SwinGame.ScreenWidth() - HOTKEYS_FUNC, 350);
            SwinGame.DrawText(UtilityFunctions.BlueKey.ToString(), Color.White, SwinGame.ScreenWidth() - HOTKEYS_BIND, 350);
            // Pink key
            SwinGame.DrawText("Pink key", Color.AntiqueWhite, SwinGame.ScreenWidth() - HOTKEYS_FUNC, 400);
            SwinGame.DrawText(UtilityFunctions.PinkKey.ToString(), Color.White, SwinGame.ScreenWidth() - HOTKEYS_BIND, 400);
            // Cheats key
            SwinGame.DrawText("Cheats key", Color.AntiqueWhite, SwinGame.ScreenWidth() - HOTKEYS_FUNC, 450);
            SwinGame.DrawText(UtilityFunctions.CheatsKey.ToString(), Color.White, SwinGame.ScreenWidth() - HOTKEYS_BIND, 450);
            // maximise key
            SwinGame.DrawText("Fullscreen key", Color.AntiqueWhite, SwinGame.ScreenWidth() - HOTKEYS_FUNC, 500);
            SwinGame.DrawText(UtilityFunctions.MaxKey.ToString(), Color.White, SwinGame.ScreenWidth() - HOTKEYS_BIND, 500);
        }
        /// <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 AI_LEFT     = 50;
            const int AI_TOP      = 350;

            if (UtilityFunctions.ShowShipsCheat)
            {
                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.DrawText(GameController.AiGameSetting(), Color.White, GameResources.GameFont("Menu"), AI_LEFT, AI_TOP);

            //Draws Ships
            foreach (ShipName sn in Enum.GetValues(typeof(ShipName)))
            {
                if (object.ReferenceEquals(GameController.ComputerPlayer.Ship(sn), null))
                {
                }
                else
                {
                    if (GameController.ComputerPlayer.Ship(sn).IsDestroyed)
                    {
                        int i = 0;
                        i = (int)sn - 1;
                        int rowTop  = 122 + (2 + 40) * GameController.ComputerPlayer.Ship(sn).Row + 3;
                        int colLeft = 349 + (2 + 40) * GameController.ComputerPlayer.Ship(sn).Column + 3;
                        if (i >= 0)
                        {
                            string shipName   = null;
                            int    shipHeight = 0;
                            int    shipWidth  = 0;
                            int    cellHeight = 40;
                            int    SHIP_GAP   = 3;
                            int    cellWidth  = 40;
                            int    cellGap    = 2;
                            int    j          = (int)GameController.ComputerPlayer.Ship(sn).CurrentShipColour;
                            if (GameController.ComputerPlayer.Ship(sn).Direction == Direction.LeftRight)
                            {
                                shipName   = "ShipLR" + GameController.ComputerPlayer.Ship(sn).Size + "a" + j;
                                shipHeight = cellHeight - (SHIP_GAP * 2);
                                shipWidth  = (cellWidth + cellGap) * GameController.ComputerPlayer.Ship(sn).Size - (SHIP_GAP * 2) - cellGap;
                            }
                            else
                            {
                                //Up down
                                shipName   = "ShipUD" + GameController.ComputerPlayer.Ship(sn).Size + "a" + j;
                                shipHeight = (cellHeight + cellGap) * GameController.ComputerPlayer.Ship(sn).Size - (SHIP_GAP * 2) - cellGap;
                                shipWidth  = cellWidth - (SHIP_GAP * 2);
                            }
                            //FIX HERE!!!
                            SwinGame.DrawBitmap(GameResources.GameImage(shipName), colLeft, rowTop);

                            //    SwinGame.FillRectangle(Color.LightBlue, SHIPS_LEFT, SHIPS_TOP + i * SHIPS_HEIGHT, SHIPS_WIDTH, SHIPS_HEIGHT)
                            //Else
                            //    SwinGame.FillRectangle(Color.Gray, SHIPS_LEFT, SHIPS_TOP + i * SHIPS_HEIGHT, SHIPS_WIDTH, SHIPS_HEIGHT)
                        }

                        //SwinGame.DrawRectangle(Color.Black, SHIPS_LEFT, SHIPS_TOP + i * SHIPS_HEIGHT, SHIPS_WIDTH, SHIPS_HEIGHT)
                        //SwinGame.DrawText(sn.ToString(), Color.Black, GameFont("Courier"), SHIPS_LEFT + TEXT_OFFSET, SHIPS_TOP + i * SHIPS_HEIGHT)
                    }
                }
            }
        }
Ejemplo n.º 12
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);
     SwinGame.DrawText(MessageTurn, TURN_COLOR, GameResources.GameFont("Courier"), FIELD_LEFT, MESSAGE_TURN);
 }