/// <summary>
        /// Draws the deployment screen showing the field and the ships
        /// that the player can deploy.
        /// </summary>
        public static void DrawDeployment()
        {
            UtilityFunctions.DrawField(GameController.HumanPlayer.PlayerGrid, GameController.HumanPlayer, true);

            // Draw the Left/Right and Up/Down buttons
            if (_currentDirection == Direction.LeftRight)
            {
                SwinGame.DrawBitmap(GameResources.GetImage("LeftRightButton"), LEFT_RIGHT_BUTTON_LEFT, TOP_BUTTONS_TOP);
            }
            /////////////////////////////////////////////////////// Todo /////////////////////////////////////////////////////////
            // SwinGame.DrawText("U/D", Color.Gray, GameFont("Menu"), UP_DOWN_BUTTON_LEFT, TOP_BUTTONS_TOP)
            // SwinGame.DrawText("L/R", Color.White, GameFont("Menu"), LEFT_RIGHT_BUTTON_LEFT, TOP_BUTTONS_TOP)
            else
            {
                SwinGame.DrawBitmap(GameResources.GetImage("UpDownButton"), LEFT_RIGHT_BUTTON_LEFT, TOP_BUTTONS_TOP);
                /////////////////////////////////////////////////////// Todo /////////////////////////////////////////////////////////
                // SwinGame.DrawText("U/D", Color.White, GameFont("Menu"), UP_DOWN_BUTTON_LEFT, TOP_BUTTONS_TOP)
                // SwinGame.DrawText("L/R", Color.Gray, GameFont("Menu"), LEFT_RIGHT_BUTTON_LEFT, TOP_BUTTONS_TOP)
            }

            // DrawShips
            foreach (ShipName sn in Enum.GetValues(typeof(ShipName)))
            {
                int i;
                i = (int)sn - 1;
                if (i >= 0)
                {
                    if (sn == _selectedShip)
                    {
                        SwinGame.DrawBitmap(GameResources.GetImage("SelectedShip"), SHIPS_LEFT, SHIPS_TOP + i * SHIPS_HEIGHT);
                        /////////////////////////////////////////////////////// Todo /////////////////////////////////////////////////////////
                        // 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)
                    }

                    /////////////////////////////////////////////////////// Todo /////////////////////////////////////////////////////////
                    // 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)
                }
            }

            if (GameController.HumanPlayer.ReadyToDeploy)
            {
                SwinGame.DrawBitmap(GameResources.GetImage("PlayButton"), PLAY_BUTTON_LEFT, TOP_BUTTONS_TOP);
                /////////////////////////////////////////////////////// Todo /////////////////////////////////////////////////////////
                // SwinGame.FillRectangle(Color.LightBlue, PLAY_BUTTON_LEFT, PLAY_BUTTON_TOP, PLAY_BUTTON_WIDTH, PLAY_BUTTON_HEIGHT)
                // SwinGame.DrawText("PLAY", Color.Black, GameFont("Courier"), PLAY_BUTTON_LEFT + TEXT_OFFSET, PLAY_BUTTON_TOP)
            }

            SwinGame.DrawBitmap(GameResources.GetImage("RandomButton"), RANDOM_BUTTON_LEFT, TOP_BUTTONS_TOP);
            UtilityFunctions.DrawMessage();
        }
Ejemplo n.º 2
0
        private static void AddAnimation(int row, int col, string image)
        {
            Sprite s;
            Bitmap imgObj;

            imgObj = GameResources.GetImage(image);
            imgObj.SetCellDetails(40, 40, 3, 3, 7);
            AnimationScript animation;

            animation = SwinGame.LoadAnimationScript("splash.txt");
            s         = SwinGame.CreateSprite(imgObj, animation);
            s.X       = FIELD_LEFT + col * (CELL_WIDTH + CELL_GAP);
            s.Y       = FIELD_TOP + row * (CELL_HEIGHT + CELL_GAP);
            s.StartAnimation("splash");
            _Animations.Add(s);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Draws the background for the current state of the game
        /// </summary>
        public static void DrawBackground()
        {
            switch (GameController.CurrentState)
            {
            case GameState.ViewingMainMenu: {
                SwinGame.DrawBitmap(GameResources.GetImage("Menu"), 0, 0);
                break;
            }

            case GameState.ViewingGameMenu: {
                break;
            }

            case GameState.AlteringSettings: {
                break;
            }

            case GameState.ViewingHighScores: {
                SwinGame.DrawBitmap(GameResources.GetImage("Menu"), 0, 0);
                break;
            }

            case GameState.Discovering: {
                SwinGame.DrawBitmap(GameResources.GetImage("Discovery"), 0, 0);
                //   DiscoveryController.HandleDiscoveryInput();
                break;
            }

            case GameState.EndingGame: {
                SwinGame.DrawBitmap(GameResources.GetImage("Discovery"), 0, 0);
                break;
            }

            case GameState.Deploying: {
                SwinGame.DrawBitmap(GameResources.GetImage("Deploy"), 0, 0);
                break;
            }

            default: {
                SwinGame.ClearScreen();
                break;
            }
            }

            SwinGame.DrawFramerate(675, 585);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Draws the player's grid and ships.
        /// </summary>
        /// <param name="grid">the grid to show</param>
        /// <param name="player">the player to show the ships of</param>
        /// <param name="small">true if the small grid is shown</param>
        /// <param name="showShips">true if ships are to be shown</param>
        /// <param name="left">the left side of the grid</param>
        /// <param name="top">the top of the grid</param>
        /// <param name="width">the width of the grid</param>
        /// <param name="height">the height of the grid</param>
        /// <param name="cellWidth">the width of each cell</param>
        /// <param name="cellHeight">the height of each cell</param>
        /// <param name="cellGap">the gap between the cells</param>
        private static void DrawCustomField(ISeaGrid grid, Player player, bool small, bool showShips, int left, int top, int width, int height, int cellWidth, int cellHeight, int cellGap)
        {
            /////////////////////////////////////////////////////// Todo /////////////////////////////////////////////////////////
            //SwinGame.FillRectangle(Color.Blue, left, top, width, height);

            int rowTop;
            int colLeft;

            // Draw the grid
            for (int row = 0; row < 10; row++)
            {
                rowTop = top + (cellGap + cellHeight) * row;

                for (int col = 0; col < 10; col++)
                {
                    colLeft = left + (cellGap + cellWidth) * col;
                    Color fillColor = default;
                    bool  draw      = true;

                    switch (grid[row, col])
                    {
                    case TileView.Ship: {
                        draw = false;
                        break;
                    }

                    /////////////////////////////////////////////////////// Todo /////////////////////////////////////////////////////////
                    // If small Then fillColor = _SMALL_SHIP Else fillColor = _LARGE_SHIP
                    case TileView.Miss: {
                        if (small)
                        {
                            fillColor = SMALL_MISS;
                        }
                        else
                        {
                            fillColor = LARGE_MISS;
                        }
                        break;
                    }

                    case TileView.Hit: {
                        if (small)
                        {
                            fillColor = SMALL_HIT;
                        }
                        else
                        {
                            fillColor = LARGE_HIT;
                        }
                        break;
                    }

                    case TileView.Sea: {
                        if (small)
                        {
                            fillColor = SMALL_SEA;
                        }
                        else
                        {
                            draw = false;
                        }
                        break;
                    }
                    }

                    if (draw)
                    {
                        SwinGame.FillRectangle(fillColor, colLeft, rowTop, cellWidth, cellHeight);
                        if (!small)
                        {
                            SwinGame.DrawRectangle(OUTLINE_COLOR, colLeft, rowTop, cellWidth, cellHeight);
                        }
                    }
                }
            }

            if (!showShips)
            {
                return;
            }

            int    shipHeight, shipWidth;
            string shipName;

            // Draw the ships
            foreach (Ship s in player)
            {
                if (s is null || !s.IsDeployed)
                {
                    continue;
                }
                rowTop  = top + (cellGap + cellHeight) * s.Row + SHIP_GAP;
                colLeft = left + (cellGap + cellWidth) * s.Column + SHIP_GAP;
                if (s.Direction == Direction.LeftRight)
                {
                    shipName   = "ShipLR" + s.Size;
                    shipHeight = cellHeight - SHIP_GAP * 2;
                    shipWidth  = (cellWidth + cellGap) * s.Size - SHIP_GAP * 2 - cellGap;
                }
                else
                {
                    // Up down
                    shipName   = "ShipUD" + s.Size;
                    shipHeight = (cellHeight + cellGap) * s.Size - SHIP_GAP * 2 - cellGap;
                    shipWidth  = cellWidth - SHIP_GAP * 2;
                }

                if (!small)
                {
                    //should it draw several tiny ships
                    //Putting in the wrong shipName
                    SwinGame.DrawBitmap(GameResources.GetImage(shipName), colLeft, rowTop);
                }
                else
                {
                    SwinGame.FillRectangle(SHIP_FILL_COLOR, colLeft, rowTop, shipWidth, shipHeight);
                    SwinGame.DrawRectangle(SHIP_OUTLINE_COLOR, colLeft, rowTop, shipWidth, shipHeight);
                }
            }
        }