示例#1
0
        protected override void ReadXml(XElement xTemplate)
        {
            var tileset = xTemplate.Element("tileset");

            if (tileset != null)
            {
                ExternalTileset = new TiledTileset(tileset);
            }

            TemplateObject = new TiledObject(xTemplate.Element("object"));
        }
示例#2
0
 private void ReadFromSource(TiledTileset source)
 {
     if (source.FirstGid != 0)
     {
         FirstGid = source.FirstGid;
     }
     Name         = source.Name;
     TileWidth    = source.TileWidth;
     TileHeight   = source.TileHeight;
     Spacing      = source.Spacing;
     Margin       = source.Margin;
     TileCount    = source.TileCount;
     Columns      = source.Columns;
     Offset       = source.Offset;
     Grid         = source.Grid;
     Properties   = source.Properties;
     TerrainTypes = source.TerrainTypes;
     Tiles        = source.Tiles;
     WangSets     = source.WangSets;
 }
示例#3
0
        protected override void ReadXml(XElement xTileset)
        {
            var firstGid = xTileset.Attribute("firstgid");

            if (firstGid != null)
            {
                FirstGid = (int)firstGid;
            }

            Source = (string)xTileset.Attribute("source");
            if (Source != null)
            {
                Source = System.IO.Path.Combine(xTileset.BaseUri, "../", Source);
                var ts = new TiledTileset(Source);
                ReadFromSource(ts);
            }
            else
            {
                Name       = (string)xTileset.Attribute("name");
                TileWidth  = (int)xTileset.Attribute("tilewidth");
                TileHeight = (int)xTileset.Attribute("tileheight");

                var spacing = xTileset.Attribute("spacing");
                if (spacing != null)
                {
                    Spacing = (int)spacing;
                }

                var margin = xTileset.Attribute("margin");
                if (margin != null)
                {
                    Margin = (int)margin;
                }

                TileCount = (int)xTileset.Attribute("tilecount");
                Columns   = (int)xTileset.Attribute("columns");

                var offset = xTileset.Element("tileoffset");
                if (offset != null)
                {
                    Offset = new TiledOffset(offset);
                }

                var grid = xTileset.Element("grid");
                if (grid != null)
                {
                    Grid = new TiledGrid(grid);
                }

                Properties = ReadProperties(xTileset.Element("properties"));

                var image = xTileset.Element("image");
                if (image != null)
                {
                    Image = new TiledImage(image);
                }

                TerrainTypes = new List <TiledTerrain>();
                var xTerrainTypes = xTileset.Element("terraintypes");
                if (xTerrainTypes != null)
                {
                    foreach (var xTerrain in xTerrainTypes.Elements("terrain"))
                    {
                        TerrainTypes.Add(new TiledTerrain(xTerrain));
                    }
                }

                Tiles = new List <TiledTile>();
                foreach (var xTile in xTileset.Elements("tile"))
                {
                    Tiles.Add(new TiledTile(xTile));
                }

                WangSets = new List <WangSet>();
                var xWangSets = xTileset.Element("wangsets");
                if (xWangSets != null)
                {
                    foreach (var xWangSet in xWangSets.Elements("wangset"))
                    {
                        WangSets.Add(new WangSet(xWangSet));
                    }
                }
            }
        }