/// <summary> /// Gets the tiles along a path or null if any invalid tiles are encountered. /// </summary> /// <param name="map">The map.</param> /// <param name="path">The path.</param> public IEnumerable <Coordinates> GetTiles(Map map, IEnumerable <Point> path) { var bresenham = new Bresenham <Coordinates>((x, y) => new Coordinates(x, y)); var lastPosition = path.First(); var tiles = new List <Coordinates>(); foreach (var position in path.Skip(1)) { var start = map.PositionToCoordinates(position); var end = map.PositionToCoordinates(lastPosition); var coordinates = bresenham.GetCoordinates(start.X, start.Y, end.X, end.Y); if (coordinates.Any(c => !CheckCoordinates(c.X, c.Y))) { return(null); } else { tiles.AddRange(coordinates); } lastPosition = position; } return(tiles); }