示例#1
0
        /// <summary>
        /// Called when the current frame has changed.  Update the controls accordingly.
        /// </summary>
        public void UpdateAnimations()
        {
            foreach (GUIAnimationChannel animation in AnimationChannels)
            {
                GUIControl control = animation.Control;
                if (control == null)
                {
                    continue;
                }

                // Find the bracketing keyframes
                KeyFrame startFrame = null;
                KeyFrame endFrame   = null;

                foreach (KeyFrame keyFrame in animation.KeyFrames)
                {
                    if (keyFrame.Frame <= Frame)
                    {
                        startFrame = keyFrame;
                    }
                    else if (keyFrame.Frame > Frame && endFrame == null)
                    {
                        endFrame = keyFrame;
                    }
                }

                // Now that we have the start and end frame, figure out the updated specifics
                // for this control
                if (startFrame == null && endFrame == null)
                {
                    continue;
                }

                float factor = 0.0f;
                if (startFrame != null && endFrame != null)
                {
                    factor = (float)(Frame - startFrame.Frame) / (float)(endFrame.Frame - startFrame.Frame);
                    factor = (float)Math.Round(factor, 3);
                    factor = Otter.Interface.Utilities.CalculateEase(factor, (int)startFrame.EaseFunction, startFrame.EaseAmount);
                }

                // Give the factor only a 3 decimal precision.
                factor = (float)Math.Round(factor, 3);
                control.ApplyKeyFrame(startFrame, endFrame, factor);
            }
        }