示例#1
0
        public void Update(float delta)
        {
            if (Paused || !Playing)
            {
                return;
            }

            AnimationKeyFrame curKF = null;

            for (int i = frames.Count - 1; i >= 0; i--)
            {
                if (Time > frames[i].TimeLocation)
                {
                    curKF = frames[i];
                    break;
                }
            }

            Time += delta * TimeModifier;

            if (Time > getLastFrame().TimeLocation)
            {
                AnimationCompleted?.Invoke();

                if (Loop)
                {
                    Time    = 0;
                    Playing = true;
                }
                else
                {
                    Time    = getLastFrame().TimeLocation;
                    Playing = false;
                }
            }

            AnimationKeyFrame curKF2 = null;

            for (int i = frames.Count - 1; i >= 0; i--)
            {
                if (Time > frames[i].TimeLocation)
                {
                    curKF2 = frames[i];
                    break;
                }
            }

            if (curKF != curKF2)
            {
                KeyframeReached?.Invoke(curKF2);
            }
        }
示例#2
0
 public Pose getCurrentPose()
 {
     for (int i = frames.Count - 1; i >= 0; i--)
     {
         if (Time > frames[i].TimeLocation)
         {
             AnimationKeyFrame next = frames[(i + 1) % frames.Count];
             return(Pose.Lerp(frames[i].Pose, next.Pose, MathHelper.Clamp((Time - frames[i].TimeLocation) / (next.TimeLocation - frames[i].TimeLocation), 0, 1), frames[i].transitionType));
         }
         else if (Time == frames[i].TimeLocation)
         {
             return(frames[i].Pose);
         }
     }
     return(null);
 }