From acea7b2e728787a0d83bbf83c8c1f042d2c32e7e Mon Sep 17 00:00:00 2001 From: chai <215380520@qq.com> Date: Mon, 3 Jun 2024 10:15:45 +0800 Subject: + plugins project --- .../Serialization/TiledMapTilesetContent.cs | 76 ++++++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 Plugins/MonoGame.Extended/source/MonoGame.Extended.Tiled/Serialization/TiledMapTilesetContent.cs (limited to 'Plugins/MonoGame.Extended/source/MonoGame.Extended.Tiled/Serialization/TiledMapTilesetContent.cs') diff --git a/Plugins/MonoGame.Extended/source/MonoGame.Extended.Tiled/Serialization/TiledMapTilesetContent.cs b/Plugins/MonoGame.Extended/source/MonoGame.Extended.Tiled/Serialization/TiledMapTilesetContent.cs new file mode 100644 index 0000000..fa04c31 --- /dev/null +++ b/Plugins/MonoGame.Extended/source/MonoGame.Extended.Tiled/Serialization/TiledMapTilesetContent.cs @@ -0,0 +1,76 @@ +using System.Collections.Generic; +using System.Xml.Serialization; + +namespace MonoGame.Extended.Tiled.Serialization +{ + [XmlRoot(ElementName = "tileset")] + public class TiledMapTilesetContent + { + public TiledMapTilesetContent() + { + TileOffset = new TiledMapTileOffsetContent(); + Tiles = new List(); + Properties = new List(); + } + + [XmlAttribute(AttributeName = "firstgid")] + public int FirstGlobalIdentifier { get; set; } + + [XmlAttribute(AttributeName = "source")] + public string Source { get; set; } + + [XmlAttribute(AttributeName = "name")] + public string Name { get; set; } + + // Deprecated as of Tiled 1.9.0 (replaced by "class" attribute) + [XmlAttribute(DataType = "string", AttributeName = "type")] + public string Type { get; set; } + + [XmlAttribute(DataType = "string", AttributeName = "class")] + public string Class { get; set; } + + [XmlAttribute(AttributeName = "tilewidth")] + public int TileWidth { get; set; } + + [XmlAttribute(AttributeName = "tileheight")] + public int TileHeight { get; set; } + + [XmlAttribute(AttributeName = "spacing")] + public int Spacing { get; set; } + + [XmlAttribute(AttributeName = "margin")] + public int Margin { get; set; } + + [XmlAttribute(AttributeName = "columns")] + public int Columns { get; set; } + + [XmlAttribute(AttributeName = "tilecount")] + public int TileCount { get; set; } + + [XmlElement(ElementName = "tileoffset")] + public TiledMapTileOffsetContent TileOffset { get; set; } + + [XmlElement(ElementName = "grid")] + public TiledMapTilesetGridContent Grid { get; set; } + + [XmlElement(ElementName = "tile")] + public List Tiles { get; set; } + + [XmlArray("properties")] + [XmlArrayItem("property")] + public List Properties { get; set; } + + [XmlElement(ElementName = "image")] + public TiledMapImageContent Image { get; set; } + + public bool ContainsGlobalIdentifier(int globalIdentifier) + { + return globalIdentifier >= FirstGlobalIdentifier && globalIdentifier < FirstGlobalIdentifier + TileCount; + } + + public override string ToString() + { + return $"{Name}: {Image}"; + } + } +} -- cgit v1.1-26-g67d0