コード例 #1
0
ファイル: Animation.cs プロジェクト: gartoks/GameEngineX
        public override void Initialize()
        {
            this.animationTimer = new OneTimeTimer();

            RunTime = 1;
            Paused  = true;
        }
コード例 #2
0
        public float GetValue(float time, IAnimationTimer animationTimer, InterpolatorDelegate interpolator)
        {
            if (!this.keyframes.Any())
            {
                return(0);
            }

            KeyValuePair <float, float> minTime = this.keyframes.First();
            KeyValuePair <float, float> maxTime = this.keyframes.Last();

            float startTime = StartingTime;

            time = startTime + AnimationTimer.Value(time, FinishingTime - startTime);

            if (time <= minTime.Key)
            {
                return(minTime.Value);
            }

            if (time >= maxTime.Key)
            {
                return(maxTime.Value);
            }

            KeyValuePair <float, float> prevTime = this.keyframes.First(kf => kf.Key >= time);
            KeyValuePair <float, float> succTime = this.keyframes.First(kf => kf.Key > prevTime.Value);

            float dt = succTime.Key - prevTime.Key;
            float t  = (time - prevTime.Key) / dt;

            return(interpolator.Invoke(t, prevTime.Value, succTime.Value));
        }
コード例 #3
0
        public Timeline(IAnimationTimer animationTimer, InterpolatorDelegate interpolator)
        {
            this.keyframes = new SortedDictionary <float, float>();

            AnimationTimer = animationTimer;
            Interpolator   = interpolator;
        }
コード例 #4
0
 public static IAnimationTimer CreateRef(this IAnimationTimer objectRef) =>
 ((IAnimationTimer)objectRef.CreateRef(typeof(IAnimationTimer)));
コード例 #5
0
 internal void <.cctor> b__18_2(IAnimationTimer innerRefT, Delegate handler)
 {
     innerRefT.RenderingTooSlow -= ((RenderingTooSlowEventHandler)handler);
 }
コード例 #6
0
 internal void <.cctor> b__18_1(IAnimationTimer innerRefT, Delegate handler)
 {
     innerRefT.PreUpdate -= ((EventHandler)handler);
 }