private XmlElement MakeBoneRefNode(XmlDocument scml, Animation.Frame frame, Element element, int frameId, SpriteIdProvider spriteIdProvider, SymbolIdProvider symbolIdProvider) { var boneRef = scml.CreateElement(string.Empty, "bone_ref", string.Empty); var id = symbolIdProvider.GetId(frame, element); boneRef.SetAttribute("id", id.ToString()); boneRef.SetAttribute("timeline", (id + spriteIdProvider.IdMap.Count).ToString()); boneRef.SetAttribute("key", frameId.ToString()); return(boneRef); }
private XmlElement MakeObjectRefNode(XmlDocument scml, Animation.Frame frame, Element element, int frameId, int elementId, SpriteIdProvider spriteIdProvider, SymbolIdProvider symbolIdProvider) { var objectRef = scml.CreateElement(string.Empty, "object_ref", string.Empty); var id = spriteIdProvider.GetId(frame, element).ToString(); objectRef.SetAttribute("id", id); objectRef.SetAttribute("parent", symbolIdProvider.GetId(frame, element).ToString()); objectRef.SetAttribute("timeline", id); objectRef.SetAttribute("key", frameId.ToString()); objectRef.SetAttribute("z_index", (frame.ElementCount - elementId).ToString()); return(objectRef); }
private List <XmlElement> MakeTimelineNodes(XmlDocument scml, Bank bank, FileIdProvider fileIdProvider) { var rate = (int)(MsPerS / bank.Rate); var spriteIdProvider = new SpriteIdProvider(bank, AnimationFile.AnimData.HashToName); var idToTimeline = new Dictionary <int, XmlElement>(); foreach (var name in spriteIdProvider.IdMap.Keys) { var timeline = scml.CreateElement(string.Empty, "timeline", string.Empty); var id = spriteIdProvider.IdMap[name]; timeline.SetAttribute("id", id.ToString()); timeline.SetAttribute("name", name); idToTimeline.Add(id, timeline); } var symbolIdProvider = new SymbolIdProvider(bank, AnimationFile.AnimData.HashToName); foreach (var name in symbolIdProvider.IdMap.Keys) { var timeline = scml.CreateElement(string.Empty, "timeline", string.Empty); var id = symbolIdProvider.IdMap[name]; timeline.SetAttribute("id", (id + spriteIdProvider.IdMap.Count).ToString()); timeline.SetAttribute("name", name); timeline.SetAttribute("object_type", "bone"); idToTimeline.Add(id + spriteIdProvider.IdMap.Count, timeline); } var frameId = 0; foreach (var frame in bank.FramesList) { foreach (var element in frame.ElementsList) { idToTimeline[spriteIdProvider.GetId(frame, element)].AppendChild( MakeTimelineKeyNode(scml, element, frameId, rate, fileIdProvider, ChildType.Sprite)); idToTimeline[symbolIdProvider.GetId(frame, element) + spriteIdProvider.IdMap.Count] .AppendChild(MakeTimelineKeyNode(scml, element, frameId, rate, fileIdProvider, ChildType.Bone)); } frameId++; } var timelines = new List <XmlElement>(); foreach (var timeline in idToTimeline.Values) { timelines.Add(timeline); } return(timelines); }
private XmlElement MakeMainlineKeyNode(XmlDocument scml, Animation.Frame frame, int frameId, int rate, SpriteIdProvider spriteIdProvider, SymbolIdProvider symbolIdProvider) { var key = scml.CreateElement(string.Empty, "key", string.Empty); key.SetAttribute("id", frameId.ToString()); key.SetAttribute("time", (frameId * rate).ToString()); var elementId = 0; foreach (var element in frame.ElementsList) { key.AppendChild(MakeBoneRefNode(scml, frame, element, frameId, spriteIdProvider, symbolIdProvider)); key.AppendChild(MakeObjectRefNode(scml, frame, element, frameId, elementId++, spriteIdProvider, symbolIdProvider)); } return(key); }
private XmlElement MakeMainlineNode(XmlDocument scml, Animation.Bank bank, HashSet <string> boneNames) { XmlElement mainline = scml.CreateElement(string.Empty, "mainline", string.Empty); int rate = (int)(MsPerS / bank.Rate); int frameId = 0; SpriteIdProvider spriteIdProvider = new SpriteIdProvider(bank, AnimationFile.HashToName); SymbolIdProvider symbolIdProvider = new SymbolIdProvider(bank, spriteIdProvider.IdMap.Count, AnimationFile.HashToName); foreach (string name in symbolIdProvider.IdMap.Keys) { boneNames.Add(name); } foreach (Animation.Frame frame in bank.FramesList) { mainline.AppendChild(MakeMainlineKeyNode(scml, frame, frameId++, rate, spriteIdProvider, symbolIdProvider)); } return(mainline); }