Exemplo n.º 1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="transition">遷移定義</param>
        /// <param name="initialValue">初期値</param>
        /// <param name="repeat">遷移を繰り返すかどうか</param>
        public TransitionPlayer(Transition <T> transition, T initialValue, bool repeat = false)
        {
            this.DefaultInterpolate = transition.DefaultInterpolate;

            Future          = new Queue <TransitionKey <T> >(transition.Keys);
            Past            = new Queue <TransitionKey <T> >();
            PreviousKey     = new TransitionKey <T>(initialValue, 0);
            CurrentKey      = Future.Dequeue();
            CurrentEstimate = 0;
            IsFinished      = false;
            Repeat          = repeat;
        }
Exemplo n.º 2
0
        private void Update(float timeDelta)
        {
            // 中断 or 終了しているなら内部状態を更新しない
            if (IsFinished)
            {
                return;
            }

            CurrentEstimate += timeDelta;
            if (CurrentEstimate >= CurrentKey.Duration)
            {
                if (Future.Any())
                {
                    Past.Enqueue(CurrentKey);
                    PreviousKey      = CurrentKey;
                    CurrentKey       = Future.Dequeue();
                    CurrentEstimate -= CurrentKey.Duration;
                }
                else if (Repeat)
                {
                    Past.Enqueue(CurrentKey);
                    PreviousKey = CurrentKey;

                    var reincarnation = Future;
                    Future = Past;
                    Past   = reincarnation;

                    CurrentKey       = Future.Dequeue();
                    CurrentEstimate -= CurrentKey.Duration;
                }
                else
                {
                    IsFinished      = true;
                    CurrentEstimate = CurrentKey.Duration;
                }
            }
        }