private static List <int[]> GetAdjacentPositions(Seat s, SeatingMap map) { //< Bleh var adj = new List <int[]>(); foreach (int x in Enumerable.Range(s.X - 1, 3)) { foreach (int y in Enumerable.Range(s.Y - 1, 3)) { if (x == s.X && y == s.Y) { continue; } var pos = new int[] { x, y }; if (map.IsValid(pos)) { adj.Add(pos); } } } return(adj); }
private static List <int[]> GetVisiblePositions(Seat s, SeatingMap map) { var startPos = new int[] { s.X, s.Y }; var seats = new List <int[]>(); foreach (var dir in Directions) { //< Get the 'next' position along this direction var pos = GetNextPosition(startPos, dir); //< While the 'next' position is valid (to the map) -> check if it's a seat mafk while (map.IsValid(pos)) { //< Check if we're a seat - if so, grab that position and halt (first visible) if (map.Grid[pos[0], pos[1]].IsSeat()) { seats.Add(pos); break; } //< Move onto the next position pos = GetNextPosition(pos, dir); } } return(seats); }
public static List <int[]> GetNeighbours(Seat s, SeatingMap map) { return(map.SearchFirstVisible ? GetVisiblePositions(s, map) : GetAdjacentPositions(s, map)); }