public static bool ParseAnimations(UFile file, List <SpriteStudioAnim> animations) { var textures = new List <UFile>(); var cells = new List <SpriteStudioCell>(); if (!ParseCellMaps(file, textures, cells)) { return(false); } var xmlDoc = XDocument.Load(file); if (xmlDoc.Root == null) { return(false); } var nameSpace = xmlDoc.Root.Name.Namespace; var anims = xmlDoc.Descendants(nameSpace + "anime"); foreach (var animXml in anims) { var animName = animXml.Descendants(nameSpace + "name").First().Value; int fps, frameCount; if (!int.TryParse(animXml.Descendants(nameSpace + "fps").First().Value, out fps)) { continue; } if (!int.TryParse(animXml.Descendants(nameSpace + "frameCount").First().Value, out frameCount)) { continue; } var anim = new SpriteStudioAnim { Name = animName, Fps = fps, FrameCount = frameCount }; var animParts = animXml.Descendants(nameSpace + "partAnime"); foreach (var animPart in animParts) { NodeAnimationData data; FillNodeData(nameSpace, animPart, cells, out data); anim.NodesData.Add(animPart.Descendants(nameSpace + "partName").First().Value, data); } animations.Add(anim); } return(true); }
public static bool ParseAnimations(UFile file, List<SpriteStudioAnim> animations) { var textures = new List<UFile>(); var cells = new List<SpriteStudioCell>(); if (!ParseCellMaps(file, textures, cells)) return false; var xmlDoc = XDocument.Load(file); if (xmlDoc.Root == null) return false; var nameSpace = xmlDoc.Root.Name.Namespace; var anims = xmlDoc.Descendants(nameSpace + "anime"); foreach (var animXml in anims) { var animName = animXml.Descendants(nameSpace + "name").First().Value; int fps, frameCount; if (!int.TryParse(animXml.Descendants(nameSpace + "fps").First().Value, out fps)) continue; if (!int.TryParse(animXml.Descendants(nameSpace + "frameCount").First().Value, out frameCount)) continue; var anim = new SpriteStudioAnim { Name = animName, Fps = fps, FrameCount = frameCount }; var animParts = animXml.Descendants(nameSpace + "partAnime"); foreach (var animPart in animParts) { NodeAnimationData data; FillNodeData(nameSpace, animPart, cells, out data); anim.NodesData.Add(animPart.Descendants(nameSpace + "partName").First().Value, data); } animations.Add(anim); } return true; }