Пример #1
0
        public virtual void Update(GameTime gameTime)
        {
            foreach (Transition transition in this.activeTransitions)
            {
                if (transition.Ready)
                {
                    transition.Start(gameTime);
                }
                else
                {
                    transition.Update(gameTime);
                }
            }

            // TODO: Unify active transitions with movement transitions after transition work is finished
            this.activeTransitions.Where(transition => transition.Done).ToList().ForEach(transition => transition.Stop());
            this.activeTransitions.RemoveAll(transition => transition.Done);

            if (this.movementTransition != null)
            {
                if (this.movementTransition.Ready)
                {
                    this.movementTransition.Start(gameTime);
                }
                else if (this.movementTransition.IsRunning)
                {
                    this.movementTransition.Update(gameTime);
                }
                else
                {
                    this.movementTransition.Stop();
                    this.movementTransition = null;
                }
            }
        }
Пример #2
0
        /// <remark>
        /// Need to tackle initiating identical/opposite time transitions while one is already running causing troughs/peaks of speed
        /// </remark>
        public void AddMovementTransition(PositionProfile destinationProfile, OnFinish onFinish = null)
        {
            Vector2 destinationPosition = destinationProfile.CalculatePosition(this.parentBounds, this.GetSize());

            if (movementTransition != null && movementTransition.Done)
            {
                movementTransition?.Stop();
            }
            movementTransition          = new MovementTransition(this.GetPosition(), destinationPosition, destinationProfile, TransitionSpeed.Fast, Move);
            movementTransition.OnFinish = onFinish;
        }