Beispiel #1
0
        private void AddGroupLayerToElement(TmxGroupLayer groupLayer, XElement xmlRoot)
        {
            // Add a game object for this grouping
            XElement xmlGroup = new XElement("GameObject");

            xmlGroup.SetAttributeValue("name", groupLayer.Name);

            PointF offset  = PointFToUnityVector(groupLayer.Offset);
            float  depth_z = CalculateLayerDepth(groupLayer);

            xmlGroup.SetAttributeValue("x", offset.X);
            xmlGroup.SetAttributeValue("y", offset.Y);
            xmlGroup.SetAttributeValue("z", depth_z);

            // Add the group layer data component
            {
                XElement component = new XElement("GroupLayer",
                                                  new XAttribute("opacity", groupLayer.Opacity),
                                                  new XAttribute("offset-x", groupLayer.Offset.X),
                                                  new XAttribute("offset-y", groupLayer.Offset.Y));
                xmlGroup.Add(component);
            }

            // Add all children
            foreach (var child in groupLayer.LayerNodes)
            {
                AddLayerNodeToElement(child, xmlGroup);
            }

            // Finally, add the node to the root
            xmlRoot.Add(xmlGroup);
        }
        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);
        }
        public static TmxGroupLayer FromXml(XElement xml, TmxLayerNode parent, TmxMap tmxMap)
        {
            TmxGroupLayer tmxGroupLayer = new TmxGroupLayer(parent, tmxMap);

            tmxGroupLayer.FromXmlInternal(xml);
            return(tmxGroupLayer);
        }
Beispiel #4
0
        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);
        }
Beispiel #5
0
        public void VisitGroupLayer(TmxGroupLayer groupLayer)
        {
            // Group layer does not advance draw index
            groupLayer.DrawOrderIndex = this.drawOrderIndex;

            // But does advance buffer index
            groupLayer.DepthBufferIndex = this.depthBufferIndex++;
        }
Beispiel #6
0
        public static TmxGroupLayer FromXml(XElement xml, TmxLayerNode parent, TmxMap tmxMap)
        {
            Debug.Assert(xml.Name == "group");

            TmxGroupLayer tmxGroupLayer = new TmxGroupLayer(parent, tmxMap);

            tmxGroupLayer.FromXmlInternal(xml);
            return(tmxGroupLayer);
        }