예제 #1
0
        /// <summary>
        /// Draws the player pieces
        /// </summary>
        /// <param name="x"></param>
        /// <param name="y"></param>
        /// <param name="_gameBoard"></param>
        public void DrawPlayerPieces(int x, int y, int cellWidth, int cellHeight, Gameboard _gameBoard)
        {
            char c = '█';

            Gameboard.PlayerColor color;
            ConsoleColor          fColor = ConsoleColor.Black;
            ConsoleColor          bColor = ConsoleColor.Black;

            for (int row = 0; row < _gameBoard.MaxRows; row++)
            {
                for (int col = 0; col < _gameBoard.MaxCols; col++)
                {
                    color = _gameBoard.PositionState[row, col];
                    switch (color)
                    {
                    case Gameboard.PlayerColor.None:
                        fColor = ConsoleColor.Black;
                        break;

                    case Gameboard.PlayerColor.Red:
                        fColor = ConsoleColor.Red;
                        break;

                    case Gameboard.PlayerColor.Blue:
                        fColor = ConsoleColor.Blue;
                        break;
                    }
                    //draw piece
                    DrawChar((x + (cellWidth / 2) + 1) + ((cellWidth + 1) * col), (y + (cellHeight / 2) + 1) + ((cellHeight + 1) * row), c, fColor, bColor);
                }
            }
            Console.ForegroundColor = ConsoleColor.White;
        }
예제 #2
0
        /// <summary>
        /// Draws the game board
        /// </summary>
        /// <param name="_gameboard"></param>
        /// <param name="column"></param>
        public void DisplayGameArea(Gameboard _gameboard, int column = 0)
        {
            Console.Clear();

            _consoleMenu.DrawGrid(_gridX, _gridY, _gridRowNum, _gridColNum, _gridCellWidth, _gridCellHeight);

            _consoleMenu.DrawPlayerPieces(_gridX, _gridY, _gridCellWidth, _gridCellHeight, _gameboard);
            _consoleMenu.DrawCursor(_gridX, _gridY, _gridCellWidth, _gridCellHeight, column, _gameboard);
        }
예제 #3
0
        /// <summary>
        /// Draw the selection cursor
        /// </summary>
        /// <param name="x"></param>
        /// <param name="y"></param>
        /// <param name="_gameBoard"></param>
        /// <param name="column"></param>
        public void DrawCursor(int x, int y, int cellWidth, int cellHeight, int column, Gameboard _gameBoard)
        {
            char         c      = '█';
            ConsoleColor fColor = ConsoleColor.Black;
            ConsoleColor bColor = ConsoleColor.Black;

            //Clears Row
            WriteAt(x, y - 2, new String(' ', cellWidth * 8));

            switch (_gameBoard.CurrentRoundState)
            {
            case Gameboard.GameboardState.PlayerOneTurn:
                fColor = ConsoleColor.Red;
                break;

            case Gameboard.GameboardState.PlayerTwoTurn:
                fColor = ConsoleColor.Blue;
                break;

            default:
                fColor = ConsoleColor.Yellow;
                break;
            }
            //draw piece
            DrawChar((x + (cellWidth / 2) + 1) + ((cellWidth + 1) * column), y - 2, c, fColor, bColor);
            Console.ForegroundColor = ConsoleColor.White;
        }
예제 #4
0
 public ConsoleView(Gameboard gameboard)
 {
     _gameboard = gameboard;
     InitializeView();
 }
예제 #5
0
 /// <summary>
 /// Update the game board
 /// </summary>
 /// <param name="_gameboard"></param>
 /// <param name="column"></param>
 public void UpdateGameArea(Gameboard _gameboard, int column = 0)
 {
     _consoleMenu.DrawPlayerPieces(_gridX, _gridY, _gridCellWidth, _gridCellHeight, _gameboard);
     _consoleMenu.DrawCursor(_gridX, _gridY, _gridCellWidth, _gridCellHeight, column, _gameboard);
 }