void ParseXml(XmlNodeList nodes, string parent = "")
        {
            foreach (XmlNode node in nodes)
            {
                var bone = new Bone(
                    node.AttributeFloat("x", 0),
                    node.AttributeFloat("y", 0),
                    node.AttributeFloat("rotation", 0),
                    node.AttributeFloat("scaleX", 1),
                    node.AttributeFloat("scaleY", 1)
                    );

                bone.FlipGraphicY = node.AttributeBool("flipGraphicY", false);
                bone.FlipGraphicX = node.AttributeBool("flipGraphicX", false);
                bone.LocalFlipX   = node.AttributeBool("flipX", false);
                bone.LocalFlipY   = node.AttributeBool("flipY", false);

                var boneName = node.AttributeString("name", "base");

                var boneEntityType = Util.GetTypeFromAllAssemblies(node.AttributeString("entity"));
                var boneEntity     = (Entity)Activator.CreateInstance(boneEntityType, 0, 0);
                bone.SetEntity(boneEntity);

                if (parent == "")
                {
                    AddBone(boneName, bone);
                }
                else
                {
                    AddBone(parent, boneName, bone);
                }

                if (node.ChildNodes.Count > 0)
                {
                    ParseXml(node.ChildNodes, boneName);
                }
            }
        }
Example #2
0
        void ParseXml(XmlNodeList nodes, string parent = "") {
            foreach (XmlNode node in nodes) {
                var bone = new Bone(
                    node.AttributeFloat("x", 0),
                    node.AttributeFloat("y", 0),
                    node.AttributeFloat("rotation", 0),
                    node.AttributeFloat("scaleX", 1),
                    node.AttributeFloat("scaleY", 1)
                    );

                bone.FlipGraphicY = node.AttributeBool("flipGraphicY", false);
                bone.FlipGraphicX = node.AttributeBool("flipGraphicX", false);
                bone.LocalFlipX = node.AttributeBool("flipX", false);
                bone.LocalFlipY = node.AttributeBool("flipY", false);

                var boneName = node.AttributeString("name", "base");

                var boneEntityType = Util.GetTypeFromAllAssemblies(node.AttributeString("entity"));
                var boneEntity = (Entity)Activator.CreateInstance(boneEntityType, 0, 0);
                bone.SetEntity(boneEntity);

                if (parent == "") {
                    AddBone(boneName, bone);
                }
                else {
                    AddBone(parent, boneName, bone);
                }

                if (node.ChildNodes.Count > 0) {
                    ParseXml(node.ChildNodes, boneName);
                }
            }
        }