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
        /// <summary>
        /// Resets the tween's values to their defaults so that the tween may be re-used
        /// </summary>
        protected virtual void Reset()
        {
            // Reset all fields to default values
            this.Easing                 = TweenEasingFunctions.Linear;
            this.LoopType               = TweenLoopType.None;
            this.CurrentTime            = 0f;
            this.Delay                  = 0;
            this.AutoCleanup            = false;
            this.IsTimeScaleIndependent = false;
            this.startTime              = 0;

            // Clear all event handlers
            this.TweenLoopCompleted = null;
            this.TweenCompleted     = null;
            this.TweenPaused        = null;
            this.TweenResumed       = null;
            this.TweenStarted       = null;
            this.TweenStopped       = null;
        }
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);
        }
Beispiel #5
0
		/// <summary>
		/// Resets the tween's values to their defaults so that the tween may be re-used
		/// </summary>
		protected virtual void Reset()
		{

			// Reset all fields to default values 
			this.Easing = TweenEasingFunctions.Linear;
			this.LoopType = TweenLoopType.None;
			this.CurrentTime = 0f;
			this.Delay = 0;
			this.AutoCleanup = false;
			this.IsTimeScaleIndependent = false;
			this.startTime = 0;

			// Clear all event handlers
			this.TweenLoopCompleted = null;
			this.TweenCompleted = null;
			this.TweenPaused = null;
			this.TweenResumed = null;
			this.TweenStarted = null;
			this.TweenStopped = null;

		}
Beispiel #6
0
 /// <summary>
 /// Set the easing function of the tween
 /// </summary>
 public Tween <T> SetEasing(TweenEasingCallback easingFunction)
 {
     this.Easing = easingFunction;
     return(this);
 }