// check left of rook for (int x = 1; x < Position.x; x++) { Position dir = new Position(Position.x - x, Position.y); if (Board.Pieces[dir] is not null) break; validMoves.Add(dir); } // check right of rook for (int x = 1; x < Board.Width - Position.x; x++) { Position dir = new Position(Position.x + x, Position.y); if (Board.Pieces[dir] is not null) break; validMoves.Add(dir); } // check top of rook for (int y = 1; y < Position.y; y++) { Position dir = new Position(Position.x, Position.y - y); if (Board.Pieces[dir] is not null) break; validMoves.Add(dir); } // check top of rook for (int y = 1; y < Board.Height - Position.y; y++) { Position dir = new Position(Position.x, Position.y + y); if (Board.Pieces[dir] is not null) break; validMoves.Add(dir); }
new Position(Position.x + x, Position.y);
// check left of rook for (int x = 0; x < Position.x; x++) { Position dir = new Position(Position.x - x, Position.y); if (Board.Pieces[dir] != null) break; validMoves.Add(dir); } // check right of rook for (int x = 0; x < Board.Width - Position.x; x++) { Position dir = new Position(Position.x + x, Position.y); if (Board.Pieces[dir] != null) break; validMoves.Add(dir); }