private bool IsCorner(Coord pos, MapArea area) { Coord left = pos + Direction.LEFT; Coord right = pos + Direction.RIGHT; Coord up = pos + Direction.UP; Coord down = pos + Direction.DOWN; return(!((area.Contains(left) && area.Contains(right)) || (area.Contains(up) && area.Contains(down)))); }
private Direction GetDirection(Coord pos, MapArea area) { Coord left = pos + Direction.LEFT; Coord right = pos + Direction.RIGHT; Coord up = pos + Direction.UP; Coord down = pos + Direction.DOWN; if (area.Contains(up) && area.Contains(down)) { return(area.Contains(right) ? Direction.LEFT : Direction.RIGHT); } else { return(area.Contains(up) ? Direction.DOWN : Direction.UP); } }
public bool MapPoint(Point mappingPoint) { bool result = false; if (MapArea.Contains(mappingPoint)) { this.Points.Add(mappingPoint); result = true; } return(result); }
public static IEnumerable <Coord> Perimeter(this MapArea area) { foreach (Coord pos in area.Positions) { foreach (Coord neighbor in AdjacencyRule.EIGHT_WAY.Neighbors(pos)) { if (!area.Contains(neighbor)) { yield return(pos); break; } } } }