Beispiel #1
0
        //fills dictionary of valid moves for given direction
        //i.e. for String, should return all valid squares in which you can place your piece as a vector2
        public void fillMoveDict(int xCoord, int yCoord)
        {
            Dictionary <string, List <Vector2> > validDict = new Dictionary <string, List <Vector2> >();
            List <Vector2> validMoves = new List <Vector2>();

            //east first
            //currentsquare is where you are
            //checkedsquare is ideally where we are checking for jumps and what not
            for (int i = xCoord; i <= boardWidth; i++)
            {
                BoardSquare currentSquare = boardArray[xCoord, yCoord];
                BoardSquare checkedSquare = boardArray[i, yCoord];

                if (currentSquare.getWall1().Equals(BoardSquare.Wall.EAST) || currentSquare.getWall2().Equals(BoardSquare.Wall.EAST))
                {
                    validMoves = validMoves;
                }
                else if (checkedSquare.getWall1().Equals(BoardSquare.Wall.EAST) || checkedSquare.getWall2().Equals(BoardSquare.Wall.EAST))
                {
                    validMoves
                }
                else if (checkedSquare.isOccupied() == true)
                {
                    if (checkedSquare.getPiece() == activePlayer)
                    {
                        validMoves = validMoves;
                    }
                    else if (checkedSquare.getPiece() != activePlayer)
                    {
                        /*
                         * accounts for some weird conditions such as:
                         * jumping over player, jumping over player to find wall on other side, jumping over player to find other player on other side
                         */
                        if (boardArray[(i + 1), yCoord].getWall1().Equals(BoardSquare.Wall.EAST) ||
                            boardArray[(i + 1), yCoord].getWall2().Equals(BoardSquare.Wall.EAST) ||
                            boardArray[(i + 1), yCoord].isOccupied() == true)
                        {
                            validMoves = validMoves;
                        }
                        else
                        {
                            validMoves.Add(new Vector2(checkedSquare.getX(), checkedSquare.getY()));
                        }
                    }
                }

                validMoves.Add(new Vector2(checkedSquare.getX(), checkedSquare.getY()));
            }
        }