Example #1
0
        public void Deserialize(XElement _element, string _layerName)
        {
            layerName = _layerName;
            id        = Convert.ToInt32(_element.Attribute("id").Value);
            name      = _element.Attribute("name") != null?_element.Attribute("name").Value : null;

            type = _element.Attribute("type") != null?_element.Attribute("type").Value : null;

            x = _element.Attribute("x") != null?float.Parse(_element.Attribute("x").Value) : 0f;

            y = _element.Attribute("y") != null?float.Parse(_element.Attribute("y").Value) : 0f;

            gid = _element.Attribute("gid") != null?int.Parse(_element.Attribute("gid").Value) : 0;

            width = _element.Attribute("width") != null?float.Parse(_element.Attribute("width").Value) : 0f;

            height = _element.Attribute("height") != null?float.Parse(_element.Attribute("height").Value) : 0f;

            property = new ITU_PropertieRootMeta();
            foreach (var xNode in _element.Nodes())
            {
                var nodeEl   = xNode as XElement;
                var nodeName = nodeEl.Name.LocalName;
                if (nodeName == "properties")
                {
                    property.Deserialize(nodeEl);
                }
                else
                {
                    geometryRawValue = nodeEl.Attribute("points") != null?nodeEl.Attribute("points").Value : null;
                }
            }
        }
        public void Deserialize(XElement _element, bool _isInifite)
        {
            layerName = _element.Attribute("name").Value;

            width  = Convert.ToInt32(_element.Attribute("width").Value);
            height = Convert.ToInt32(_element.Attribute("height").Value);

            offsetX = _element.Attribute("offsetx") != null?Convert.ToSingle(_element.Attribute("offsetx").Value) : 0;

            offsetY = _element.Attribute("offsety") != null?Convert.ToSingle(_element.Attribute("offsety").Value) : 0;

            chunkList = new List <ITU_TmxLayerChunkMeta>();
            //tmx format is different between inifite and not infinite
            if (_isInifite)
            {
                var allChunkEl = _element.Element("data").Elements("chunk");

                foreach (var el in allChunkEl)
                {
                    var chunkMeta = new ITU_TmxLayerChunkMeta();
                    chunkMeta.Deserialize(el);
                    chunkList.Add(chunkMeta);
                }
            }
            else
            {
                var chunkMeta = new ITU_TmxLayerChunkMeta();
                chunkMeta.startX = 0;
                chunkMeta.startY = 0;
                chunkMeta.width  = width;
                chunkMeta.height = height;
                chunkMeta.DeserializeData(_element.Element("data").Value);
                chunkList.Add(chunkMeta);
            }

            if (_element.Element("properties") != null)
            {
                property = new ITU_PropertieRootMeta();
                property.Deserialize(_element.Element("properties"));
            }
        }
Example #3
0
 private void HandleMapPropertyNode(XElement _node)
 {
     property = new ITU_PropertieRootMeta();
     property.Deserialize(_node);
 }