private static Point2 GetTilePosition(TiledMapContent map, TiledMapTile mapTile) { switch (map.Orientation) { case TiledMapOrientationContent.Orthogonal: return(TiledMapHelper.GetOrthogonalPosition(mapTile.X, mapTile.Y, map.TileWidth, map.TileHeight)); case TiledMapOrientationContent.Isometric: return(TiledMapHelper.GetIsometricPosition(mapTile.X, mapTile.Y, map.TileWidth, map.TileHeight)); case TiledMapOrientationContent.Staggered: throw new NotImplementedException("Staggered maps are not yet implemented."); default: throw new NotSupportedException($"Tiled Map {map.Orientation} is not supported."); } }
private static IEnumerable <TiledMapTile> CreateTilesInRightUpOrder(List <TiledMapTileContent> tileLayerData, int mapWidth, int mapHeight) { for (var y = mapHeight - 1; y >= 0; y--) { for (var x = mapWidth - 1; x >= 0; x--) { var dataIndex = x + y * mapWidth; var globalIdentifier = tileLayerData[dataIndex].GlobalIdentifier; if (globalIdentifier == 0) { continue; } var tile = new TiledMapTile(globalIdentifier, (ushort)x, (ushort)y); yield return(tile); } } }
private static IEnumerable <TiledMapTile> CreateTilesInRightDownOrder( // ReSharper disable once SuggestBaseTypeForParameter List <TiledMapTileContent> tileLayerData, int mapWidth, int mapHeight) { for (var y = 0; y < mapHeight; y++) { for (var x = 0; x < mapWidth; x++) { var dataIndex = x + y * mapWidth; var globalIdentifier = tileLayerData[dataIndex].GlobalIdentifier; if (globalIdentifier == 0) { continue; } var tile = new TiledMapTile(globalIdentifier, (ushort)x, (ushort)y); yield return(tile); } } }