Ejemplo n.º 1
0
        public XElement ToXml()
        {
            XElement root = new XElement("group");

            root.SetAttributeValue("name", Name);

            for (int i = 0; i < Images.Count; ++i)
            {
                AnimationImage img     = Images[i];
                XElement       imgNode = new XElement("image");
                imgNode.SetAttributeValue("anchorx", img.AnchorX);
                imgNode.SetAttributeValue("anchory", img.AnchorY);
                //imgNode.SetAttributeValue("name", i);
                root.Add(imgNode);
            }
            return(root);
        }
Ejemplo n.º 2
0
        static public AnimationUnit Parse(XElement root)
        {
            AnimationUnit rst = new AnimationUnit();

            rst.Name = root.Attribute("name").Value;
            foreach (XElement node in root.Elements("group"))
            {
                string         groupName = node.Attribute("name").Value;
                AnimationGroup group     = new AnimationGroup();
                group.Name = groupName;
                rst.Groups.Add(group);

                int index = -1;
                foreach (XElement imageNode in node.Elements("image"))
                {
                    index++;
                    AnimationImage img = new AnimationImage();
                    img.AnchorX = int.Parse(imageNode.Attribute("anchorx").Value);
                    img.AnchorY = int.Parse(imageNode.Attribute("anchory").Value);
                    img.W       = Tools.GetXmlAttributeInt(imageNode, "w");
                    img.H       = Tools.GetXmlAttributeInt(imageNode, "h");
                    img.Name    = index.ToString();

                    string dir = "";

                    if (groupName == "skill")
                    {
                        dir = AnimationManager.SkillAnimationImagePath;
                    }
                    else
                    {
                        dir = AnimationManager.AnimationImagePath;
                    }
                    string imageFile = dir + string.Format("{0}-{1}-{2}.png", rst.Name, group.Name, index);
                    img.Url = imageFile;
                    //img.Image = Tools.GetImage(imageFile);
                    group.Images.Add(img);
                }
            }
            return(rst);
        }