public virtual AnimationFrameBase FrameForTime(int time, AnimationFrameBase startKeyFrame, AnimationFrameBase endKeyFrame) { Debug.WriteLine("Hey pal! You need to use a subclass of IFTTTAnimation."); return(startKeyFrame); }
public void AddKeyFrame(AnimationFrameBase keyFrame) { Debug.WriteLine(string.Format("Add KeyFrame Time: {0}", keyFrame.Time)); if (KeyFrames.Count() == 0) { KeyFrames.Add(keyFrame); return; } // because folks might add keyframes out of order, we have to sort here if (keyFrame.Time > ((AnimationFrameBase)KeyFrames.Last()).Time) { KeyFrames.Add(keyFrame); } else { for (int i = 0; i < KeyFrames.Count(); i++) { if (keyFrame.Time < ((AnimationFrameBase)KeyFrames [i]).Time) { KeyFrames.Add(keyFrame); // TODO atIndex:i; break; } } } _timeline = new List <AnimationFrameBase> (); for (int i = 0; i < KeyFrames.Count() - 1; i++) { AnimationFrameBase currentKeyFrame = KeyFrames [i]; AnimationFrameBase nextKeyFrame = KeyFrames [i + 1]; for (int j = currentKeyFrame.Time + (i == 0 ? 0 : 1); j <= nextKeyFrame.Time; j++) { _timeline.Add(FrameForTime(j, currentKeyFrame, nextKeyFrame)); } } _startTime = ((AnimationFrameBase)KeyFrames [0]).Time; }