public static List <TmxLayerNode> ListFromXml(XElement xmlRoot, TmxLayerNode parent, TmxMap tmxMap) { List <TmxLayerNode> nodes = new List <TmxLayerNode>(); foreach (var xmlNode in xmlRoot.Elements()) { TmxLayerNode layerNode = null; if (xmlNode.Name == "layer" || xmlNode.Name == "imagelayer") { layerNode = TmxLayer.FromXml(xmlNode, parent, tmxMap); } else if (xmlNode.Name == "objectgroup") { layerNode = TmxObjectGroup.FromXml(xmlNode, parent, tmxMap); } else if (xmlNode.Name == "group") { layerNode = TmxGroupLayer.FromXml(xmlNode, parent, tmxMap); } // If the layer is visible then add it to our list if (layerNode != null && layerNode.Visible) { nodes.Add(layerNode); } } return(nodes); }
private void ParseAllLayers(XDocument doc) { Program.WriteLine("Parsing layer elements ..."); var layers = (from item in doc.Descendants("layer") select item).ToList(); foreach (var lay in layers) { TmxLayer tmxLayer = TmxLayer.FromXml(lay, this.Layers.Count); // Layers may be ignored if (tmxLayer.Properties.GetPropertyValueAsBoolean("unity:ignore", false) == true) { // We don't care about this layer Program.WriteLine("Ignoring layer due to unity:ignore property: {0}", tmxLayer.UniqueName); continue; } int maxVertices = 65535; int numVertices = (from tileId in tmxLayer.TileIds where tileId != 0 select tileId).Count() * 4; if (numVertices > maxVertices) { Program.WriteWarning("Layer '{0}' will have more than {1} vertices (vertex count = {2}) and will be split into {3} parts by Unity.", tmxLayer.UniqueName, maxVertices, numVertices, numVertices / maxVertices + 1); } this.Layers.Add(tmxLayer); } }
public static List <TmxLayerNode> ListFromXml(XElement xmlRoot, TmxLayerNode parent, TmxMap tmxMap) { List <TmxLayerNode> list = new List <TmxLayerNode>(); foreach (XElement item in xmlRoot.Elements()) { TmxLayerNode tmxLayerNode = null; if (item.Name == (XName)"layer" || item.Name == (XName)"imagelayer") { tmxLayerNode = TmxLayer.FromXml(item, parent, tmxMap); } else if (item.Name == (XName)"objectgroup") { tmxLayerNode = TmxObjectGroup.FromXml(item, parent, tmxMap); } else if (item.Name == (XName)"group") { tmxLayerNode = TmxGroupLayer.FromXml(item, parent, tmxMap); } if (tmxLayerNode != null && tmxLayerNode.Visible && tmxLayerNode.Ignore != IgnoreSettings.True) { list.Add(tmxLayerNode); } } return(list); }
private void ParseAllLayers(XDocument doc) { Logger.WriteLine("Parsing layer elements ..."); // Parse "layer"s and "imagelayer"s var layers = (from item in doc.Descendants() where (item.Name == "layer" || item.Name == "imagelayer") select item).ToList(); foreach (var lay in layers) { TmxLayer tmxLayer = TmxLayer.FromXml(lay, this); // Layers may be ignored if (tmxLayer.Ignore == TmxLayer.IgnoreSettings.True) { // We don't care about this layer Logger.WriteLine("Ignoring layer due to unity:ignore = True property: {0}", tmxLayer.Name); continue; } this.Layers.Add(tmxLayer); } }