Beispiel #1
0
        protected override void configureTween()
        {
            if (this.tween == null)
            {
                if (this.target == null || string.IsNullOrEmpty(componentType) || string.IsNullOrEmpty(memberName))
                {
                    return;
                }

                this.component = target.GetComponent(this.componentType);
                if (component == null)
                {
                    return;
                }

                this.easingFunc = TweenEasingFunctions.GetFunction(this.easingType);

                this.tween = (Tween <T>)
                             component.TweenProperty <T>(memberName)
                             .SetEasing(this.modifyEasing)
                             .OnStarted((x) => { onStarted(); })
                             .OnStopped((x) => { onStopped(); })
                             .OnPaused((x) => { onPaused(); })
                             .OnResumed((x) => { onResumed(); })
                             .OnLoopCompleted((x) => { onLoopCompleted(); })
                             .OnCompleted((x) => { onCompleted(); });
            }

            var currentValue = TweenNamedProperty <T> .GetCurrentValue(component, memberName);

            var interpolator = DaikonForge.Tween.Interpolation.Interpolators.Get <T>();

            var actualStartValue = this.startValue;

            if (this.startValueType == TweenStartValueType.SyncOnRun)
            {
                actualStartValue = currentValue;
            }

            var actualEndValue = this.endValue;

            if (this.endValueType == TweenEndValueType.SyncOnRun)
            {
                actualEndValue = currentValue;
            }
            else if (this.endValueType == TweenEndValueType.Relative)
            {
                actualEndValue = interpolator.Add(actualEndValue, actualStartValue);
            }

            this.tween
            .SetStartValue(actualStartValue)
            .SetEndValue(actualEndValue)
            .SetDelay(this.startDelay, this.assignStartValueBeforeDelay)
            .SetDuration(this.duration)
            .SetLoopType(this.LoopType)
            .SetLoopCount(this.loopCount)
            .SetPlayDirection(this.playDirection);
        }
Beispiel #2
0
        protected override void configureTween()
        {
            if (this.tween == null)
            {
                this.easingFunc = TweenEasingFunctions.GetFunction(this.easingType);

                this.tween = (Tween <Vector3>)
                             transform.TweenPosition(this.useLocalPosition)
                             .SetEasing(this.modifyEasing)
                             .OnStarted((x) => { onStarted(); })
                             .OnStopped((x) => { onStopped(); })
                             .OnPaused((x) => { onPaused(); })
                             .OnResumed((x) => { onResumed(); })
                             .OnLoopCompleted((x) => { onLoopCompleted(); })
                             .OnCompleted((x) => { onCompleted(); });
            }

            var currentValue = (this.useLocalPosition) ? transform.localPosition : transform.position;

            var actualStartValue = this.startValue;

            if (this.startValueType == TweenStartValueType.SyncOnRun)
            {
                actualStartValue = currentValue;
            }

            var actualEndValue = this.endValue;

            if (this.endValueType == TweenEndValueType.SyncOnRun)
            {
                actualEndValue = currentValue;
            }
            else if (this.endValueType == TweenEndValueType.Relative)
            {
                actualEndValue += actualStartValue;
            }

            this.tween
            .SetStartValue(actualStartValue)
            .SetEndValue(actualEndValue)
            .SetDelay(this.startDelay, this.assignStartValueBeforeDelay)
            .SetDuration(this.duration)
            .SetLoopType(this.LoopType)
            .SetLoopCount(this.loopCount)
            .SetPlayDirection(this.playDirection);
        }
Beispiel #3
0
        void Update()
        {
            if (grid == null || !invalid)
            {
                return;
            }
            float delta = Time.deltaTime;

            if (rowCount == 0)
            {
                Init();
            }
            for (int r = 0; r < rowCount; r++)
            {
                float old = rowDelay[r];
                rowDelay[r] = Math.Min(rowDelay[r] + delta * speed, 1);
                float time          = Math.Max(0, rowDelay[r]);
                float interpolation = TweenEasingFunctions.GetFunction(easeType)(time);
                for (int c = 0; c < colCount; c++)
                {
                    Transform t = grid.GetCell(r, c);
                    if (t != null)
                    {
                        animator(r, t, cellScales[r, c], cellPos[r, c], interpolation);
                    }
                }
                if (animateBackground)
                {
                    Transform bg = grid.GetBackground(r);
                    if (bg != null)
                    {
                        animator(r, bg, bgScales[r], bgPos[r], interpolation);
                    }
                }
                if (r >= grid.rowHeader && old <= 0 && time > 0)
                {
                    foreach (UITableAnimEventListener l in listeners)
                    {
                        l.OnRowAnimBegin(r - grid.rowHeader);
                    }
                }
                if (r >= grid.rowHeader && old < 1 && time >= 1)
                {
                    foreach (UITableAnimEventListener l in listeners)
                    {
                        l.OnRowAnimEnd(r - grid.rowHeader);
                    }
                }
            }
            if (rowCount > 0 && rowDelay[rowCount - 1] >= 1)
            {
                for (int r = 0; r < rowCount; r++)
                {
                    Transform bg = grid.GetBackground(r);
                    if (bg != null)
                    {
                        NGUIUtil.UpdateCollider(bg);
                    }
                }
                invalid = false;
                foreach (UITableAnimEventListener l in listeners)
                {
                    l.OnAnimEnd();
                }
            }
        }
Beispiel #4
0
        protected override void configureTween()
        {
            if (target == null)
            {
                target = gameObject.GetComponent <Renderer>();

                if (target == null)
                {
                    if (this.tween != null)
                    {
                        tween.Stop();
                        tween.Release();
                        tween = null;
                    }

                    return;
                }
            }

            if (this.tween == null)
            {
                this.easingFunc = TweenEasingFunctions.GetFunction(this.easingType);

                this.tween = (Tween <Color>)
                             Target.TweenColor()
                             .SetEasing(this.modifyEasing)
                             .OnStarted((x) => { onStarted(); })
                             .OnStopped((x) => { onStopped(); })
                             .OnPaused((x) => { onPaused(); })
                             .OnResumed((x) => { onResumed(); })
                             .OnLoopCompleted((x) => { onLoopCompleted(); })
                             .OnCompleted((x) => { onCompleted(); });
            }

            var currentValue = tween.CurrentValue;

            var actualStartValue = this.startValue;

            if (this.startValueType == TweenStartValueType.SyncOnRun)
            {
                actualStartValue = currentValue;
            }

            var actualEndValue = this.endValue;

            if (this.endValueType == TweenEndValueType.SyncOnRun)
            {
                actualEndValue = currentValue;
            }
            else if (this.endValueType == TweenEndValueType.Relative)
            {
                actualEndValue += actualStartValue;
            }

            this.tween
            .SetStartValue(actualStartValue)
            .SetEndValue(actualEndValue)
            .SetDelay(this.startDelay, this.assignStartValueBeforeDelay)
            .SetDuration(this.duration)
            .SetLoopType(this.LoopType)
            .SetLoopCount(this.loopCount)
            .SetPlayDirection(this.playDirection);
        }