using System; using System.Collections.Generic; namespace Spine { public class AnimationStateData { public SkeletonData SkeletonData { get; private set; } private Dictionary, float> animationToMixTime = new Dictionary, float>(); public AnimationStateData (SkeletonData skeletonData) { SkeletonData = skeletonData; } public void SetMix (String fromName, String toName, float duration) { Animation from = SkeletonData.FindAnimation(fromName); if (from == null) throw new ArgumentException("Animation not found: " + fromName); Animation to = SkeletonData.FindAnimation(toName); if (to == null) throw new ArgumentException("Animation not found: " + toName); SetMix(from, to, duration); } 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."); animationToMixTime.Add(new KeyValuePair(from, to), duration); } public float GetMix (Animation from, Animation to) { KeyValuePair key = new KeyValuePair(from, to); float duration; animationToMixTime.TryGetValue(key, out duration); return duration; } } }