private void WriteLayer(ContentWriter writer, TiledMapLayerContent layer) { writer.Write((byte)layer.Type); writer.Write(layer.Name ?? string.Empty); writer.Write(layer.Visible); writer.Write(layer.Opacity); writer.Write(layer.OffsetX); writer.Write(layer.OffsetY); writer.WriteTiledMapProperties(layer.Properties); switch (layer.Type) { case TiledMapLayerType.ImageLayer: WriteImageLayer(writer, (TiledMapImageLayerContent)layer); break; case TiledMapLayerType.TileLayer: WriteTileLayer(writer, (TiledMapTileLayerContent)layer); break; case TiledMapLayerType.ObjectLayer: WriteObjectLayer(writer, (TiledMapObjectLayerContent)layer); break; case TiledMapLayerType.GroupLayer: WriteLayers(writer, ((TiledMapGroupLayerContent)layer).Layers); break; default: throw new ArgumentOutOfRangeException(nameof(layer.Type)); } }
private static void WriteLayer(ContentWriter output, TiledMapLayerContent layer) { output.Write((byte)layer.Type); output.Write(layer.Name ?? string.Empty); output.Write(layer.Visible); output.Write(layer.Opacity); output.Write(layer.OffsetX); output.Write(layer.OffsetY); output.WriteTiledMapProperties(layer.Properties); switch (layer.Type) { case TiledMapLayerType.ImageLayer: WriteImageLayer(output, (TiledMapImageLayerContent)layer); break; case TiledMapLayerType.TileLayer: WriteTileLayer(output, (TiledMapTileLayerContent)layer); break; case TiledMapLayerType.ObjectLayer: WriteObjectLayer(output, (TiledMapObjectLayerContent)layer); break; default: throw new ArgumentOutOfRangeException(nameof(layer.Type)); } if (layer.Type != TiledMapLayerType.ObjectLayer) { WriteModels(output, layer.Models); } }
private static void WriteMetaData(ContentWriter writer, TiledMapContent map) { writer.Write(map.Width); writer.Write(map.Height); writer.Write(map.TileWidth); writer.Write(map.TileHeight); writer.Write(ColorHelper.FromHex(map.BackgroundColor)); writer.Write((byte)map.RenderOrder); writer.Write((byte)map.Orientation); writer.WriteTiledMapProperties(map.Properties); }
private static void WriteTilesetTile(ContentWriter output, TiledMapTilesetTileContent tilesetTile) { output.Write(tilesetTile.LocalIdentifier); output.Write(tilesetTile.Frames.Count); foreach (var frame in tilesetTile.Frames) { output.Write(frame.TileIdentifier); output.Write(frame.Duration); } output.WriteTiledMapProperties(tilesetTile.Properties); }
private static void WriteTilesetTile(ContentWriter writer, TiledMapTilesetTileContent tilesetTile) { writer.Write(tilesetTile.LocalIdentifier); writer.Write(tilesetTile.Type); writer.Write(tilesetTile.Frames.Count); writer.Write(tilesetTile.Objects.Count); foreach (var @object in tilesetTile.Objects) { WriteObject(writer, @object); } foreach (var frame in tilesetTile.Frames) { writer.Write(frame.TileIdentifier); writer.Write(frame.Duration); } writer.WriteTiledMapProperties(tilesetTile.Properties); }
public static void WriteTileset(ContentWriter writer, TiledMapTilesetContent tileset, IExternalReferenceRepository externalReferenceRepository) { var externalReference = externalReferenceRepository.GetExternalReference <Texture2DContent>(tileset.Image.Source); writer.WriteExternalReference(externalReference); writer.Write(tileset.TileWidth); writer.Write(tileset.TileHeight); writer.Write(tileset.TileCount); writer.Write(tileset.Spacing); writer.Write(tileset.Margin); writer.Write(tileset.Columns); writer.Write(tileset.Tiles.Count); foreach (var tilesetTile in tileset.Tiles) { WriteTilesetTile(writer, tilesetTile); } writer.WriteTiledMapProperties(tileset.Properties); }
private static void WriteTileset(ContentWriter output, TiledMapTilesetContent tileset) { output.Write(Path.ChangeExtension(tileset.Image.Source, null)); output.Write(tileset.FirstGlobalIdentifier); output.Write(tileset.TileWidth); output.Write(tileset.TileHeight); output.Write(tileset.TileCount); output.Write(tileset.Spacing); output.Write(tileset.Margin); output.Write(tileset.Columns); output.Write(tileset.Tiles.Count); foreach (var tilesetTile in tileset.Tiles) { WriteTilesetTile(output, tilesetTile); } output.WriteTiledMapProperties(tileset.Properties); }
private static void WriteObject(ContentWriter writer, TiledMapObjectContent @object) { var type = GetObjectType(@object); writer.Write((byte)type); writer.Write(@object.Identifier); writer.Write(@object.Name ?? string.Empty); writer.Write(@object.Type ?? string.Empty); writer.Write(@object.X); writer.Write(@object.Y); writer.Write(@object.Width); writer.Write(@object.Height); writer.Write(@object.Rotation); writer.Write(@object.Visible); writer.WriteTiledMapProperties(@object.Properties); switch (type) { case TiledMapObjectType.Rectangle: case TiledMapObjectType.Ellipse: break; case TiledMapObjectType.Tile: writer.Write(@object.GlobalIdentifier); break; case TiledMapObjectType.Polygon: WritePolyPoints(writer, @object.Polygon.Points); break; case TiledMapObjectType.Polyline: WritePolyPoints(writer, @object.Polyline.Points); break; default: throw new ArgumentOutOfRangeException(); } }