AnimationSequence.Animations.Animation3DBehavior.Update C# (CSharp) Method

Update() protected method

protected Update ( System.TimeSpan gameTime ) : void
gameTime System.TimeSpan
return void
        protected override void Update(TimeSpan gameTime)
        {
            if (completed)
            {
                return;
            }

            this.time += gameTime;
            if (time <= this.animation.TotalTime)
            {
                float amount = (float)(this.time.TotalSeconds / this.animation.TotalTime.TotalSeconds);

                if (this.animation.TransformationType.HasFlag(AnimationSlot.TransformationTypes.Position))
                {
                    Vector3 deltaPosition = Vector3.Lerp(this.animation.StartPosition, this.animation.EndPosition, amount);
                    this.transform3D.LocalPosition = deltaPosition;
                }
                if (this.animation.TransformationType.HasFlag(AnimationSlot.TransformationTypes.Rotation))
                {
                    Vector3 deltaRotation = Vector3.Lerp(this.animation.StartRotation, this.animation.EndRotation, amount);
                    this.transform3D.LocalRotation = deltaRotation;
                }
                if (this.animation.TransformationType.HasFlag(AnimationSlot.TransformationTypes.Scale))
                {
                    Vector3 deltaScale = Vector3.Lerp(this.animation.StartScale, this.animation.EndScale, amount);
                    this.transform3D.LocalScale = deltaScale;
                }
            }
            else
            {
                if (this.animation.TransformationType.HasFlag(AnimationSlot.TransformationTypes.Position))
                {
                    this.transform3D.LocalPosition = this.animation.EndPosition;
                }
                if (this.animation.TransformationType.HasFlag(AnimationSlot.TransformationTypes.Rotation))
                {
                    this.transform3D.LocalRotation = this.animation.EndRotation;
                }
                if (this.animation.TransformationType.HasFlag(AnimationSlot.TransformationTypes.Scale))
                {
                    this.transform3D.LocalScale = this.animation.EndScale;
                }

                this.completed = true;
                if (this.Completed != null)
                {
                    this.Completed(this, new EventArgs());
                }
            }
        }