//Configure the animation, usually set from loading a file public void AnimConfig(string animationName, bool loop, string GoToAnim = "") { bool foundAnim = false; foreach (CustAnim anim in animations) { if (anim.name.ToUpper() == animationName.ToUpper()) { anim.loop = loop; anim.goToAnim = GoToAnim; foundAnim = true; break; } } if (!foundAnim) { CustAnim anim = new CustAnim(); anim.name = animationName; anim.loop = loop; anim.goToAnim = GoToAnim; animations.Add(anim); } }
//Add a keyframe to the animation public void AddKeyFrame(string animName, KeyFrame frame) { bool foundAnim = false; foreach (CustAnim anim in animations) { if (anim.name.ToUpper() == animName.ToUpper()) { if (!anim.objs.Contains(frame.objID)) { //Creation frame! frame.creationFrame = true; anim.objs.Add(frame.objID); anim.objDescs.Add(frame.objDesc); } if (anim.duration < frame.frameTime) { anim.duration = frame.frameTime; //Increase duration value } anim.keyFrames.Add(frame); foundAnim = true; break; } } if (!foundAnim) { CustAnim anim = new CustAnim(); anim.name = animName; if (!anim.objs.Contains(frame.objID)) { //Creation frame! frame.creationFrame = true; anim.objs.Add(frame.objID); anim.objDescs.Add(frame.objDesc); } anim.keyFrames.Add(frame); animations.Add(anim); } }
//Add a variable keyframe to the animation public void AddVarFrame(string animName, VarFrame frame) { bool foundAnim = false; foreach (CustAnim anim in animations) { if (anim.name.ToUpper() == animName.ToUpper()) { if (!anim.variables.ContainsKey(frame.varName)) { //Creation frame! frame.creationFrame = true; anim.variables.Add(frame.varName, frame.value); } anim.varFrames.Add(frame); foundAnim = true; break; } } if (!foundAnim) { CustAnim anim = new CustAnim(); anim.name = animName; if (!anim.variables.ContainsKey(frame.varName)) { //Creation frame! frame.creationFrame = true; anim.variables.Add(frame.varName, frame.value); } anim.varFrames.Add(frame); animations.Add(anim); } }