Esempio n. 1
0
        private void SelectPiece(int x, int y, GameSetup gameSetup)
        {
            if (Board.Board[x, y] != null)
            {
                //Only select if the pieces of the team that has the turn
                if (Board.Board[x, y].Team == Piece.teams.attackers && Board.State == PlayBoard.gameState.attackerTurn)
                {
                    SelectedPiece       = Board.Board[x, y];
                    SelectedPieceColumn = x;
                    SelectedPieceRow    = y;
                }

                if (Board.Board[x, y].Team == Piece.teams.defenders && Board.State == PlayBoard.gameState.defenderTurn)
                {
                    SelectedPiece       = Board.Board[x, y];
                    SelectedPieceColumn = x;
                    SelectedPieceRow    = y;
                }
            }
        }
Esempio n. 2
0
        private void PieceControl(MouseState mouseState, Point mousePoint, int x, int y, GameSetup gameSetup)
        {
            var spriteWidth  = 40;
            var spriteHeight = 40;
            var boardWidth   = spriteWidth * Board.Columns;
            var boardHeight  = spriteHeight * Board.Rows;
            var drawStartX   = (WindowWidth / 2) - (boardWidth / 2);
            var drawStartY   = (WindowHeight / 2) - (boardHeight / 2);
            var posX         = (x * spriteWidth) + drawStartX;
            var posY         = (y * spriteHeight) + drawStartY;

            if (collisionHandler.PointColisionWithBox(mousePoint.X, mousePoint.Y, posX, posY, spriteWidth, spriteHeight))
            {
                if (MousePress(mouseState))
                {
                    SelectPiece(x, y, gameSetup);
                    MovePiece(x, y);

                    //Find legal moves, and return the updated board
                    Board = legalMove.FindLegalMoves(Board, SelectedPiece, SelectedPieceColumn, SelectedPieceRow);
                }
            }
        }