WaveEngine.Components.Animation.Animation3D.Update C# (CSharp) 메소드

Update() 보호된 메소드

Updates the animation.
protected Update ( System.TimeSpan gameTime ) : void
gameTime System.TimeSpan /// The game time. ///
리턴 void
        protected override void Update(TimeSpan gameTime)
        {
            if (this.State == AnimationState.Playing)
            {
                this.totalAnimTime += gameTime;

                this.internalFrame = (int)(this.totalAnimTime.TotalMilliseconds / this.timePerFrame.TotalMilliseconds);

                if (!this.Backwards)
                {
                    // Is forward
                    if (this.targetFrame >= 0)
                    {
                        // TargetFrame enabled
                        this.frame = this.lastFrame + this.internalFrame; // Frame Increment

                        if (this.frame >= this.targetFrame)
                        {
                            // If animation completed
                            this.totalAnimTime = TimeSpan.Zero;

                            if (this.Loop)
                            {
                                // Is looped
                                this.frame = this.numFrames - 1;
                                this.frame = this.lastFrame;
                            }
                            else
                            {
                                this.lastFrame = this.frame = this.targetFrame;
                                this.targetFrame = -1;
                                this.StopAnimation();
                            }
                        }
                    }
                    else
                    {
                        // Normal
                        this.frame = this.internalFrame; // Frame Increment

                        if (this.frame >= this.numFrames)
                        {
                            // If animation completed
                            this.totalAnimTime = TimeSpan.Zero;

                            if (this.Loop)
                            {
                                // Is looped
                                this.frame = this.numFrames - 1;
                            }
                            else
                            {
                                this.frame = this.lastFrame = this.numFrames - 1;
                                this.StopAnimation();
                            }
                        }
                    }

                    // Throw KeyFrameEvents
                    if (this.OnKeyFrameEvent != null && this.keyFrameEvents.ContainsKey(this.currentAnimation))
                    {
                        Dictionary<int, string> listKeys = this.keyFrameEvents[this.currentAnimation];
                        int i = this.prevFrame;
                        while (i != this.frame)
                        {
                            i = (i + 1) % this.numFrames;

                            if (listKeys.ContainsKey(i))
                            {
                                this.OnKeyFrameEvent(this, new StringEventArgs(listKeys[i]));
                            }
                        }
                    }
                }
                else
                {
                    // Is backwards
                    if (this.targetFrame >= 0)
                    {
                        // TargetFrame enabled
                        this.frame = this.lastFrame - this.internalFrame; // Frame Increment

                        if (this.frame <= this.targetFrame)
                        {
                            // Active Target frame
                            this.totalAnimTime = TimeSpan.Zero;
                            this.lastFrame = this.frame = this.targetFrame;
                            this.targetFrame = -1;
                            this.StopAnimation();
                        }
                    }
                    else
                    {
                        // Normal backwards
                        this.frame = (this.numFrames - 1) - this.internalFrame; // Frame Increment

                        if (this.frame < 0)
                        {
                            // If animation completed
                            this.totalAnimTime = TimeSpan.Zero;

                            if (this.Loop)
                            {
                                // Is looped
                                this.frame = 0;
                            }
                            else
                            {
                                this.frame = this.lastFrame = 0;
                                this.StopAnimation();
                            }
                        }
                    }

                    // Throw KeyFrameEvents
                    if (this.OnKeyFrameEvent != null && this.keyFrameEvents.ContainsKey(this.currentAnimation))
                    {
                        Dictionary<int, string> listKeys = this.keyFrameEvents[this.currentAnimation];
                        int i = this.prevFrame;

                        while (i != this.frame)
                        {
                            i = i - 1;

                            if (i < 0)
                            {
                                i = this.numFrames - 1;
                            }

                            if (listKeys.ContainsKey(i))
                            {
                                this.OnKeyFrameEvent(this, new StringEventArgs(listKeys[i]));
                            }
                        }
                    }
                }

                this.prevFrame = this.frame;
            }
        }