private Dictionary <string, SkeletalKeyframe.DataContainer> GetStateData(XElement serializedData) { Dictionary <string, SkeletalKeyframe.DataContainer> data = new Dictionary <string, SkeletalKeyframe.DataContainer>(); foreach (XElement bone in serializedData.Elements("bone")) { SkeletalKeyframe.DataContainer boneData = new SkeletalKeyframe.DataContainer(); boneData.Deserialize(bone); data.Add(bone.Attribute("id").Value, boneData); } return(data); }
private static void AddSkeletalKeyframe(string sequenceName, XElement xmlFrameData) { SkeletalKeyframe newKeyframe = new SkeletalKeyframe(); newKeyframe.DurationInMilliseconds = (int)xmlFrameData.Attribute("duration"); foreach (XElement bone in xmlFrameData.Elements("bonedata")) { SkeletalKeyframe.DataContainer boneKeyframeData = new SkeletalKeyframe.DataContainer(); if (bone.Attribute("rotation") != null) { boneKeyframeData.Rotation = Utility.RectifyAngle(MathHelper.ToRadians((float)bone.Attribute("rotation"))); } if (bone.Attribute("scale") != null) { boneKeyframeData.Scale = (float)bone.Attribute("scale"); } if ((bone.Attribute("offset-x") != null) && (bone.Attribute("offset-y") != null)) { boneKeyframeData.Offset = new Vector2((float)bone.Attribute("offset-x"), (float)bone.Attribute("offset-y")); } if (bone.Element("texture") != null) { if (bone.Element("texture").Attribute("name") != null) { boneKeyframeData.TextureName = bone.Element("texture").Attribute("name").Value; } if ((bone.Attribute("origin-x") != null) && (bone.Attribute("origin-y") != null)) { boneKeyframeData.Origin = new Vector2((float)bone.Attribute("origin-x"), (float)bone.Attribute("origin-y")); } if ((bone.Element("texture").Attribute("frame-x") != null) && (bone.Element("texture").Attribute("frame-y") != null) && (bone.Element("texture").Attribute("frame-width") != null) && (bone.Element("texture").Attribute("frame-height") != null)) { Rectangle frame = new Rectangle((int)bone.Element("texture").Attribute("frame-x"), (int)bone.Element("texture").Attribute("frame-y"), (int)bone.Element("texture").Attribute("frame-width"), (int)bone.Element("texture").Attribute("frame-height")); boneKeyframeData.SourceArea = frame; } } newKeyframe.BoneAnimationData.Add(bone.Attribute("id").Value, boneKeyframeData); } AddKeyframe(sequenceName, newKeyframe); }
private Dictionary<string, SkeletalKeyframe.DataContainer> GetStateData(XElement serializedData) { Dictionary<string, SkeletalKeyframe.DataContainer> data = new Dictionary<string, SkeletalKeyframe.DataContainer>(); foreach (XElement bone in serializedData.Elements("bone")) { SkeletalKeyframe.DataContainer boneData = new SkeletalKeyframe.DataContainer(); boneData.Deserialize(bone); data.Add(bone.Attribute("id").Value, boneData); } return data; }