Beispiel #1
0
        /// <summary>
        /// Advance the currently playing clips, transitions, etc, and return any metachannel events that
        /// have occurred during the elapsed time.
        /// </summary>
        /// <param name="gameTime"></param>
        /// <returns></returns>
        public void Update(GameTime gameTime)
        {
            ActiveControlEvents = AnimationControlEvents.None;

            if (ActiveTransition == null ||
                (transitionTime == TimeSpan.Zero && !CurrentState.CanTransitionOut()))
            {
                // We're either completely in a given state, or we can't begin the transition just yet.
                CurrentState.AdvanceTime(gameTime.ElapsedGameTime);
                ActiveControlEvents |= CurrentState.GetActiveControlEvents();
            }
            else
            {
                // A transition is in progress.
                if (ActiveTransition.Type != TransitionType.Frozen)
                {
                    CurrentState.AdvanceTime(gameTime.ElapsedGameTime);
                    ActiveControlEvents |= CurrentState.GetActiveControlEvents();
                }

                nextState.AdvanceTime(gameTime.ElapsedGameTime);
                ActiveControlEvents |= nextState.GetActiveControlEvents();

                transitionTime += gameTime.ElapsedGameTime;

                // Has the transition completed?
                if (transitionTime.TotalSeconds >= ActiveTransition.DurationInSeconds)
                {
                    CurrentState = nextState;
                    blendFromCancelledTransitionPose = false;
                    if (nextState != desiredState)
                    {
                        nextState = desiredState;
                    }
                    else
                    {
                        nextState = null;
                    }
                    UpdateTransition();
                }
            }
        }