Beispiel #1
0
    /// <summary>
    /// Returns a Tween instance that is configured to animate a Transform.position property
    /// </summary>
    /// <param name="transform">The transform to be animated</param>
    /// <param name="useLocalPosition">If set to TRUE, the Transform.localPosition property will be used instead of Transform.position</param>
    public static Tween <Vector3> TweenPosition(this Transform transform, bool useLocalPosition)
    {
        var startValue = useLocalPosition ? transform.localPosition : transform.position;

        TweenAssignmentCallback <Vector3> updateFunc = null;

        if (useLocalPosition)
        {
            updateFunc = (localValue) => { transform.localPosition = localValue; }
        }
        ;
        else
        {
            updateFunc = (globalValue) => { transform.position = globalValue; }
        };

        var tween = Tween <Vector3>
                    .Obtain()
                    .SetStartValue(startValue)
                    .SetEndValue(startValue)
                    .SetDuration(1f)
                    .OnExecute(updateFunc);

        return(tween);
    }

    #endregion
}
Beispiel #2
0
    /// <summary>
    /// Returns a Tween instance that is configured to animate a Transform.eulerAngles property
    /// </summary>
    /// <param name="transform">The transform to be animated</param>
    /// <param name="useShortestPath">If set to TRUE, the rotation will follow the shortest path.</param>
    /// <param name="useLocalRotation">If set to TRUE, then Transform.localEulerAngles will be animated instead of Transform.eulerAngles</param>
    public static Tween <Vector3> TweenRotation(this Transform transform, bool useShortestPath, bool useLocalRotation)
    {
        var interpolator = useShortestPath
                        ? (Interpolator <Vector3>)EulerInterpolator.Default
                        : (Interpolator <Vector3>)Vector3Interpolator.Default;

        var startValue = useLocalRotation ? transform.localEulerAngles : transform.eulerAngles;

        TweenAssignmentCallback <Vector3> updateFunc = null;

        if (useLocalRotation)
        {
            updateFunc = (localValue) => { transform.localEulerAngles = localValue; }
        }
        ;
        else
        {
            updateFunc = (globalValue) => { transform.eulerAngles = globalValue; }
        };

        var tween = Tween <Vector3>
                    .Obtain()
                    .SetStartValue(startValue)
                    .SetEndValue(startValue)
                    .SetDuration(1f)
                    .SetInterpolator(interpolator)
                    .OnExecute(updateFunc);

        return(tween);
    }
Beispiel #3
0
        /// <summary>
        /// Returns the dfShake instance back to the object pool
        /// </summary>
        public override void Release()
        {
            // Make sure that the tween is no longer running
            Stop();

            // Reset all values to defaults
            this.StartValue   = Vector3.zero;
            this.currentValue = Vector3.zero;
            this.CurrentTime  = 0f;
            this.Delay        = 0;

            // Clear all event handlers
            this.ShakeCompleted = null;

            // Clear main callbacks
            this.Execute = null;

            // Add the shake back to the object pool
            pool.Add(this);
        }
Beispiel #4
0
        protected override void Reset()
        {
            base.Reset();

            // Reset all fields to defaults
            this.StartValue    = default(T);
            this.EndValue      = default(T);
            this.CurrentValue  = default(T);
            this.Duration      = 1f;
            this.EndIsOffset   = false;
            this.PlayDirection = TweenDirection.Forward;

            // Reset runtime variables to default values
            this.LoopCount = -1;
            this.assignStartValueBeforeDelay = true;

            // Clear main callbacks
            this.Interpolator = null;
            this.Execute      = null;
        }
Beispiel #5
0
 /// <summary>
 /// Set the assignment function for the shake
 /// </summary>
 public TweenShake OnExecute(TweenAssignmentCallback <Vector3> Execute)
 {
     this.Execute = Execute;
     return(this);
 }
Beispiel #6
0
 public TweenShake(Vector3 StartValue, float ShakeMagnitude, float ShakeDuration, float ShakeSpeed, float StartDelay, bool AutoCleanup, TweenAssignmentCallback <Vector3> OnExecute)
 {
     SetStartValue(StartValue)
     .SetShakeMagnitude(ShakeMagnitude)
     .SetDuration(ShakeDuration)
     .SetShakeSpeed(ShakeSpeed)
     .SetDelay(StartDelay)
     .SetAutoCleanup(AutoCleanup)
     .OnExecute(OnExecute);
 }
Beispiel #7
0
		/// <summary>
		/// Returns the dfShake instance back to the object pool
		/// </summary>
		public override void Release()
		{

			// Make sure that the tween is no longer running
			Stop();

			// Reset all values to defaults
			this.StartValue = Vector3.zero;
			this.currentValue = Vector3.zero;
			this.CurrentTime = 0f;
			this.Delay = 0;

			// Clear all event handlers
			this.ShakeCompleted = null;

			// Clear main callbacks
			this.Execute = null;

			// Add the shake back to the object pool
			pool.Add( this );

		}
Beispiel #8
0
		/// <summary>
		/// Set the assignment function for the shake
		/// </summary>
		public TweenShake OnExecute( TweenAssignmentCallback<Vector3> Execute )
		{
			this.Execute = Execute;
			return this;
		}
Beispiel #9
0
		public TweenShake( Vector3 StartValue, float ShakeMagnitude, float ShakeDuration, float ShakeSpeed, float StartDelay, bool AutoCleanup, TweenAssignmentCallback<Vector3> OnExecute )
		{
			SetStartValue( StartValue )
				.SetShakeMagnitude( ShakeMagnitude )
				.SetDuration( ShakeDuration )
				.SetShakeSpeed( ShakeSpeed )
				.SetDelay( StartDelay )
				.SetAutoCleanup( AutoCleanup )
				.OnExecute( OnExecute );
		}
Beispiel #10
0
 /// <summary>
 /// Sets the execution callback
 /// </summary>
 public Tween <T> OnExecute(TweenAssignmentCallback <T> function)
 {
     this.Execute = function;
     return(this);
 }