Exemplo n.º 1
0
    public List <Vector2Int> AttacksForPiece(GameObject pieceObject)
    {
        Piece      piece     = pieceObject.GetComponent <Piece>();
        Vector2Int gridPoint = GridForPiece(pieceObject);
        var        locations = piece.AttackLocations(gridPoint);

        // rules that are true for any piece!

        // get rid if off board
        locations.RemoveAll(tile => tile.x < 0 || tile.x > 7 ||
                            tile.y < 0 || tile.y > 7);

        // filter out locations without a piece
        locations.RemoveAll(tile => !PieceAtGrid(tile));
        locations.RemoveAll(tile => FriendlyPieceAt(tile));

        return(locations);
    }