static public AnimationProject Load(List <string> files) { AnimationProject rst = new AnimationProject(); foreach (var file in files) { XElement root = Tools.LoadXml("Scripts/" + file); foreach (var unit in root.Elements("animation")) { rst.Units.Add(AnimationUnit.Parse(unit)); } } return(rst); }
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); }