private bool CheckCondition(TileMap map, Vector2 cell) { foreach (var side in Conditions.Keys) { int i = 0; var cellChoices = Conditions[side].CellIndexChoices; while (i++ < Consecutive) { var adjacentCell = map.Tiles.Cells.GetFromPoint(cell.GetAdjacent(side)); if (cellChoices.Any()) { if (!cellChoices.Contains(adjacentCell)) { return(false); } } else { if (adjacentCell != map.EmptyCell) { return(false); } } } } return(true); }
public IEnumerable <ArrayGridPoint <T> > GetPointsInLine(Vector2 start, Direction dir) { Vector2 point = start; while (PointToIndex(point, -1) != -1) { yield return(new ArrayGridPoint <T>(point, this)); point = point.GetAdjacent(dir); } yield return(new ArrayGridPoint <T>(point, this)); }
public static Vector2[] GetAdjacentPoints(this Vector2 vector, bool includeDiagonal) { var sides = new List <BorderSide> { BorderSide.Left, BorderSide.Top, BorderSide.Right, BorderSide.Bottom }; if (includeDiagonal) { sides.Add(BorderSide.TopLeftCorner); sides.Add(BorderSide.TopRightCorner); sides.Add(BorderSide.BottomLeftCorner); sides.Add(BorderSide.BottomRightCorner); } return(sides.Select(side => vector.GetAdjacent(side)).ToArray()); }
public ArrayGridPoint <T> GetAdjacent(Direction side) { var adj = Position.GetAdjacent(side); return(new ArrayGridPoint <T>(adj, Grid)); }