예제 #1
0
 public static IEnumerable <Point2> NeighboursOfType(this IReadOnlyGrid <TileType> map, Point2 middle, TileType type, bool cornersIncluded = false)
 {
     for (var y = -1; y <= 1; y++)
     {
         for (var x = -1; x <= 1; x++)
         {
             if (!cornersIncluded && Math.Abs(x) == Math.Abs(y))
             {
                 continue;
             }
             if (map.At(x, y) == type)
             {
                 yield return(new Point2(middle.X + x, middle.Y + y));
             }
         }
     }
 }
예제 #2
0
 public static TileType At(this IReadOnlyGrid <TileType> map, int x, int y)
 {
     return(map.At(new Point2(x, y)));
 }