using UnityEngine; using System; using System.Collections; using System.Collections.Generic; public class GoTweenConfig { private List _tweenProperties = new List(); public List tweenProperties { get { return _tweenProperties; } } public int id; // id for finding the Tween at a later time. multiple Tweens can have the same id public float delay; // how long should we delay before starting the Tween public int iterations = 1; // number of times to iterate. -1 will loop indefinitely public int timeScale = 1; public GoLoopType loopType = Go.defaultLoopType; public GoEaseType easeType = Go.defaultEaseType; public bool isPaused; public GoUpdateType propertyUpdateType = Go.defaultUpdateType; public bool isFrom; public Action onInitHandler; public Action onBeginHandler; public Action onIterationStartHandler; public Action onUpdateHandler; public Action onIterationEndHandler; public Action onCompleteHandler; #region TweenProperty adders /// /// position tween /// public GoTweenConfig position( Vector3 endValue, bool isRelative = false ) { var prop = new PositionTweenProperty( endValue, isRelative ); _tweenProperties.Add( prop ); return this; } /// /// localPosition tween /// public GoTweenConfig localPosition( Vector3 endValue, bool isRelative = false ) { var prop = new PositionTweenProperty( endValue, isRelative, true ); _tweenProperties.Add( prop ); return this; } /// /// position path tween /// public GoTweenConfig positionPath( GoSpline path, bool isRelative = false, GoLookAtType lookAtType = GoLookAtType.None, Transform lookTarget = null ) { var prop = new PositionPathTweenProperty( path, isRelative, false, lookAtType, lookTarget ); _tweenProperties.Add( prop ); return this; } /// /// uniform scale tween (x, y and z scale to the same value) /// public GoTweenConfig scale( float endValue, bool isRelative = false ) { return this.scale( new Vector3( endValue, endValue, endValue ), isRelative ); } /// /// scale tween /// public GoTweenConfig scale( Vector3 endValue, bool isRelative = false ) { var prop = new ScaleTweenProperty( endValue, isRelative ); _tweenProperties.Add( prop ); return this; } /// /// scale through a series of Vector3s /// public GoTweenConfig scalePath( GoSpline path, bool isRelative = false ) { var prop = new ScalePathTweenProperty( path, isRelative ); _tweenProperties.Add( prop ); return this; } /// /// eulerAngle tween /// public GoTweenConfig eulerAngles( Vector3 endValue, bool isRelative = false ) { var prop = new EulerAnglesTweenProperty( endValue, isRelative ); _tweenProperties.Add( prop ); return this; } /// /// local eulerAngle tween /// public GoTweenConfig localEulerAngles( Vector3 endValue, bool isRelative = false ) { var prop = new EulerAnglesTweenProperty( endValue, isRelative, true ); _tweenProperties.Add( prop ); return this; } /// /// rotation tween /// public GoTweenConfig rotation( Vector3 endValue, bool isRelative = false ) { var prop = new RotationTweenProperty( endValue, isRelative ); _tweenProperties.Add( prop ); return this; } /// /// localRotation tween /// public GoTweenConfig localRotation( Vector3 endValue, bool isRelative = false ) { var prop = new RotationTweenProperty( endValue, isRelative, true ); _tweenProperties.Add( prop ); return this; } /// /// rotation tween as Quaternion /// public GoTweenConfig rotation( Quaternion endValue, bool isRelative = false ) { var prop = new RotationQuaternionTweenProperty( endValue, isRelative ); _tweenProperties.Add( prop ); return this; } /// /// localRotation tween as Quaternion /// public GoTweenConfig localRotation( Quaternion endValue, bool isRelative = false ) { var prop = new RotationQuaternionTweenProperty( endValue, isRelative, true ); _tweenProperties.Add( prop ); return this; } /// /// material color tween /// public GoTweenConfig materialColor( Color endValue, string colorName = "_Color", bool isRelative = false ) { var prop = new MaterialColorTweenProperty( endValue, colorName, isRelative ); _tweenProperties.Add( prop ); return this; } /// /// shake tween /// public GoTweenConfig shake( Vector3 shakeMagnitude, GoShakeType shakeType = GoShakeType.Position, int frameMod = 1, bool useLocalProperties = false ) { var prop = new ShakeTweenProperty( shakeMagnitude, shakeType, frameMod, useLocalProperties ); _tweenProperties.Add( prop ); return this; } #region generic properties /// /// generic vector2 tween /// public GoTweenConfig vector2Prop( string propertyName, Vector2 endValue, bool isRelative = false ) { var prop = new Vector2TweenProperty( propertyName, endValue, isRelative ); _tweenProperties.Add( prop ); return this; } /// /// generic vector3 tween /// public GoTweenConfig vector3Prop( string propertyName, Vector3 endValue, bool isRelative = false ) { var prop = new Vector3TweenProperty( propertyName, endValue, isRelative ); _tweenProperties.Add( prop ); return this; } /// /// generic vector4 tween /// public GoTweenConfig vector4Prop( string propertyName, Vector4 endValue, bool isRelative = false ) { var prop = new Vector4TweenProperty( propertyName, endValue, isRelative ); _tweenProperties.Add( prop ); return this; } /// /// generic vector3 path tween /// public GoTweenConfig vector3PathProp( string propertyName, GoSpline path, bool isRelative = false ) { var prop = new Vector3PathTweenProperty( propertyName, path, isRelative ); _tweenProperties.Add( prop ); return this; } /// /// generic vector3.x tween /// public GoTweenConfig vector3XProp( string propertyName, float endValue, bool isRelative = false ) { var prop = new Vector3XTweenProperty( propertyName, endValue, isRelative ); _tweenProperties.Add( prop ); return this; } /// /// generic vector3.y tween /// public GoTweenConfig vector3YProp( string propertyName, float endValue, bool isRelative = false ) { var prop = new Vector3YTweenProperty( propertyName, endValue, isRelative ); _tweenProperties.Add( prop ); return this; } /// /// generic vector3.z tween /// public GoTweenConfig vector3ZProp( string propertyName, float endValue, bool isRelative = false ) { var prop = new Vector3ZTweenProperty( propertyName, endValue, isRelative ); _tweenProperties.Add( prop ); return this; } /// /// generic color tween /// public GoTweenConfig colorProp( string propertyName, Color endValue, bool isRelative = false ) { var prop = new ColorTweenProperty( propertyName, endValue, isRelative ); _tweenProperties.Add( prop ); return this; } /// /// generic integer tween /// public GoTweenConfig intProp( string propertyName, int endValue, bool isRelative = false ) { var prop = new IntTweenProperty( propertyName, endValue, isRelative ); _tweenProperties.Add( prop ); return this; } /// /// generic float tween /// public GoTweenConfig floatProp( string propertyName, float endValue, bool isRelative = false ) { var prop = new FloatTweenProperty( propertyName, endValue, isRelative ); _tweenProperties.Add( prop ); return this; } #endregion #endregion /// /// adds a TweenProperty to the list /// public GoTweenConfig addTweenProperty( AbstractTweenProperty tweenProp ) { _tweenProperties.Add( tweenProp ); return this; } /// /// clears out all the TweenProperties /// public GoTweenConfig clearProperties() { _tweenProperties.Clear(); return this; } /// /// clears out all the TweenProperties /// public GoTweenConfig clearEvents() { onInitHandler = null; onBeginHandler = null; onIterationStartHandler = null; onUpdateHandler = null; onIterationEndHandler = null; onCompleteHandler = null; return this; } /// /// sets the delay for the tween /// public GoTweenConfig setDelay( float seconds ) { delay = seconds; return this; } /// /// sets the number of iterations. setting to -1 will loop infinitely /// public GoTweenConfig setIterations( int iterations ) { this.iterations = iterations; return this; } /// /// sets the number of iterations and the loop type. setting to -1 will loop infinitely /// public GoTweenConfig setIterations( int iterations, GoLoopType loopType ) { this.iterations = iterations; this.loopType = loopType; return this; } /// /// sets the timeScale to be used by the Tween /// public GoTweenConfig setTimeScale( int timeScale ) { this.timeScale = timeScale; return this; } /// /// sets the ease type for the Tween /// public GoTweenConfig setEaseType( GoEaseType easeType ) { this.easeType = easeType; return this; } /// /// sets whether the Tween should start paused /// public GoTweenConfig startPaused() { isPaused = true; return this; } /// /// sets the update type for the Tween /// public GoTweenConfig setUpdateType( GoUpdateType setUpdateType ) { propertyUpdateType = setUpdateType; return this; } /// /// sets if this Tween should be a "from" Tween. From Tweens use the current property as the endValue and /// the endValue as the start value /// public GoTweenConfig setIsFrom() { isFrom = true; return this; } /// /// sets if this Tween should be a "to" Tween. /// public GoTweenConfig setIsTo() { isFrom = false; return this; } /// /// sets the onInit handler for the Tween /// public GoTweenConfig onInit( Action onInit ) { onInitHandler = onInit; return this; } /// /// sets the onBegin handler for the Tween /// public GoTweenConfig onBegin( Action onBegin ) { onBeginHandler = onBegin; return this; } /// /// sets the onIterationStart handler for the Tween /// public GoTweenConfig onIterationStart( Action onIterationStart ) { onIterationStartHandler = onIterationStart; return this; } /// /// sets the onUpdate handler for the Tween /// public GoTweenConfig onUpdate( Action onUpdate ) { onUpdateHandler = onUpdate; return this; } /// /// sets the onIterationEnd handler for the Tween /// public GoTweenConfig onIterationEnd( Action onIterationEnd ) { onIterationEndHandler = onIterationEnd; return this; } /// /// sets the onComplete handler for the Tween /// public GoTweenConfig onComplete( Action onComplete ) { onCompleteHandler = onComplete; return this; } /// /// sets the id for the Tween. Multiple Tweens can have the same id and you can retrieve them with the Go class /// public GoTweenConfig setId( int id ) { this.id = id; return this; } }