void SetDistanceMap(int source) { distanceMap = new int[tileTypeMap.Length]; highestDistance = -1; for (int i = 0; i < distanceMap.Length; i++) { distanceMap[i] = RoomMath.GetManhattanDistance(i, source, width); highestDistance = Mathf.Max(highestDistance, distanceMap[i]); } }
public void RequestMove(Coordinate target) { if (RoomMath.GetManhattanDistance(target, position) == 1 && target.Inside(roomWidth, roomHeight)) { moveTarget = target; queuedMove = true; } else { Debug.LogWarning(name + string.Format(" tried invalid move to {0},{1}", target.x, target.y)); } }
public static List <int> GetPositionsAtDistance(int[] tileTypeMap, int origin, Range permissableDistance, TileType typeOfTile, bool requireStairsPosition, int width) { var matchingPositions = new List <int>(); int height = tileTypeMap.Length / width; for (int i = 0; i < tileTypeMap.Length; i++) { if (tileTypeMap[i] == (int)typeOfTile && (!requireStairsPosition || RoomMath.CoordinateOnNonCornerPerimeter(Coordinate.FromPosition(i, width), width, height)) && permissableDistance.Inside(RoomMath.GetManhattanDistance(origin, i, width))) { matchingPositions.Add(i); } } return(matchingPositions); }