Exemplo n.º 1
0
    public override List <Vector2Int> GetLegalMoves(Board boardState)
    {
        List <Vector2Int> AllowedMoves = new List <Vector2Int>();

        AllowedMoves.AddRange(ChessLogic.GetAdjacent(boardState, index, distance));
        return(AllowedMoves);
    }
Exemplo n.º 2
0
    public override List <Vector2Int> GetLegalMoves(Board boardState)
    {
        List <Vector2Int> AllowedMoves = new List <Vector2Int>();

        //Basic Moves
        List <Vector2Int> moveSpots = new List <Vector2Int>();

        moveSpots.AddRange(ChessLogic.GetAdjacent(boardState, index, distance));
        //Debug.Log(moveSpots.Count + " Potential Adjacent Moves Found");
        for (int i = 0; i < moveSpots.Count; i++)
        {
            //If it would be a capture, remove it. Pawns Can't capture adjacent
            if (boardState.boardState[moveSpots[i].x, moveSpots[i].y].chessPiece == null)
            {
                AllowedMoves.Add(moveSpots[i]);
            }
        }
        //Debug.Log(moveSpots.Count + " Legal Adjacent Moves Found");

        //Attacks on Diagonals
        List <Vector2Int> attackSpots = new List <Vector2Int>();

        attackSpots.AddRange(ChessLogic.GetDiagonals(boardState, index, 1));


        for (int i = 0; i < attackSpots.Count; i++)
        {
            //If it would be a move, not a capture, remove it. Pawns can't move diagonal
            if (boardState.boardState[attackSpots[i].x, attackSpots[i].y].chessPiece != null)
            {
                AllowedMoves.Add(attackSpots[i]);
            }
        }

        //En Passant?
        // Should This be added?
        //

        return(AllowedMoves);
    }