public void SetMix (Animation from, Animation to, float duration) { if (from == null) throw new ArgumentNullException("from cannot be null."); if (to == null) throw new ArgumentNullException("to cannot be null."); KeyValuePair<Animation, Animation> key = new KeyValuePair<Animation, Animation>(from, to); animationToMixTime.Remove(key); animationToMixTime.Add(key, duration); }
/// <summary>Adds an animation to be played delay seconds after the current or last queued animation.</summary> /// <param name="delay">May be <= 0 to use duration of previous animation minus any mix duration plus the negative delay.</param> public TrackEntry AddAnimation (int trackIndex, Animation animation, bool loop, float delay) { TrackEntry entry = new TrackEntry(); entry.animation = animation; entry.loop = loop; entry.time = 0; entry.endTime = animation.Duration; TrackEntry last = ExpandToIndex(trackIndex); if (last != null) { while (last.next != null) last = last.next; last.next = entry; } else tracks[trackIndex] = entry; if (delay <= 0) { if (last != null) delay += last.endTime - data.GetMix(last.animation, animation); else delay = 0; } entry.delay = delay; return entry; }
/// <summary>Set the current animation. Any queued animations are cleared.</summary> public TrackEntry SetAnimation (int trackIndex, Animation animation, bool loop) { TrackEntry entry = new TrackEntry(); entry.animation = animation; entry.loop = loop; entry.time = 0; entry.endTime = animation.Duration; SetCurrent(trackIndex, entry); return entry; }
// --- Animations. public void AddAnimation (Animation animation) { if (animation == null) throw new ArgumentNullException("animation cannot be null."); animations.Add(animation); }
public float GetMix (Animation from, Animation to) { KeyValuePair<Animation, Animation> key = new KeyValuePair<Animation, Animation>(from, to); float duration; if (animationToMixTime.TryGetValue(key, out duration)) return duration; return defaultMix; }