Esempio n. 1
0
        private void prepend(TweenFlowItem item)
        {
            // early out for invalid items
            if (item.tween != null && !item.tween.isValid())
            {
                return;
            }

            if (float.IsInfinity(item.duration))
            {
                Debug.LogError("adding a Tween with infinite iterations to a TweenChain is not permitted");
                return;
            }

            if (item.tween != null)
            {
                if (item.tween.isReversed != isReversed)
                {
                    Debug.LogError("adding a Tween that doesn't match the isReversed property of the TweenChain is not permitted.");
                    return;
                }

                // ensure the tween isnt already live
                Go.removeTween(item.tween);

                // ensure that the item is marked to play.
                item.tween.play();
            }

            // fix all the start times on our previous chains
            foreach (var flowItem in _tweenFlows)
            {
                flowItem.startTime += item.duration;
            }

            _tweenFlows.Insert(0, item);

            // update the duration and total duration
            duration += item.duration;

            if (iterations < 0)
            {
                totalDuration = float.PositiveInfinity;
            }
            else
            {
                totalDuration = duration * iterations;
            }
        }
Esempio n. 2
0
        /// <summary>
        /// the item being added already has a start time so no extra parameter is needed
        /// </summary>
        private void insert(TweenFlowItem item)
        {
            // early out for invalid items
            if (item.tween != null && !item.tween.isValid())
            {
                return;
            }

            if (float.IsInfinity(item.duration))
            {
                Debug.LogError("adding a Tween with infinite iterations to a TweenFlow is not permitted");
                return;
            }

            if (item.tween != null)
            {
                if (item.tween.isReversed != isReversed)
                {
                    Debug.LogError("adding a Tween that doesn't match the isReversed property of the TweenFlow is not permitted.");
                    return;
                }

                // ensure the tween isnt already live
                Go.removeTween(item.tween);

                // ensure that the item is marked to play.
                item.tween.play();
            }

            // add the item then sort based on startTimes
            _tweenFlows.Add(item);
            _tweenFlows.Sort((x, y) =>
            {
                return(x.startTime.CompareTo(y.startTime));
            });

            duration = Mathf.Max(item.startTime + item.duration, duration);

            if (iterations < 0)
            {
                totalDuration = float.PositiveInfinity;
            }
            else
            {
                totalDuration = duration * iterations;
            }
        }