public override bool containsTweenProperty(AbstractTweenProperty property) { for (int i = 0; _tweenFlows.Count > i; i++) { // skip delay items which have no tween if (_tweenFlows[i].tween == null) { continue; } if (_tweenFlows[i].tween.containsTweenProperty(property)) { return(true); } } /*foreach ( var flowItem in _tweenFlows ) * { * // skip delay items which have no tween * if ( flowItem.tween == null ) * continue; * * if ( flowItem.tween.containsTweenProperty( property ) ) * return true; * }*/ return(false); }
private static bool handleDuplicatePropertiesInTween(GoTween tween) { List <GoTween> list = tweensWithTarget(tween.target); List <AbstractTweenProperty> list2 = tween.allTweenProperties(); for (int i = 0; i < list.Count; i++) { GoTween goTween = list[i]; for (int j = 0; j < list2.Count; j++) { AbstractTweenProperty property = list2[j]; if (goTween.containsTweenProperty(property)) { if (duplicatePropertyRule == GoDuplicatePropertyRuleType.DontAddCurrentProperty) { return(true); } if (duplicatePropertyRule == GoDuplicatePropertyRuleType.RemoveRunningProperty) { goTween.removeTweenProperty(property); } return(false); } } } return(false); }
public AbstractTweenProperty clone() { AbstractTweenProperty abstractTweenProperty = MemberwiseClone() as AbstractTweenProperty; abstractTweenProperty._ownerTween = null; abstractTweenProperty._isInitialized = false; abstractTweenProperty._easeFunction = null; return(abstractTweenProperty); }
public override bool removeTweenProperty(AbstractTweenProperty property) { if (_tweenPropertyList.Contains(property)) { _tweenPropertyList.Remove(property); return(true); } return(false); }
public GoTween(object target, float duration, GoTweenConfig config, Action <AbstractGoTween> onComplete = null) { if (duration <= 0f) { duration = float.Epsilon; UnityEngine.Debug.LogError("tween duration must be greater than 0. coerced to float.Epsilon."); } base.autoRemoveOnComplete = true; base.allowEvents = true; _didInit = false; _didBegin = false; _fireIterationStart = true; this.target = target; targetType = target.GetType(); base.duration = duration; base.id = config.id; delay = config.delay; base.loopType = config.loopType; base.iterations = config.iterations; _easeType = config.easeType; easeCurve = config.easeCurve; base.updateType = config.propertyUpdateType; isFrom = config.isFrom; base.timeScale = config.timeScale; _onInit = config.onInitHandler; _onBegin = config.onBeginHandler; _onIterationStart = config.onIterationStartHandler; _onUpdate = config.onUpdateHandler; _onIterationEnd = config.onIterationEndHandler; _onComplete = config.onCompleteHandler; if (config.isPaused) { base.state = GoTweenState.Paused; } if (onComplete != null) { _onComplete = onComplete; } for (int i = 0; i < config.tweenProperties.Count; i++) { AbstractTweenProperty abstractTweenProperty = config.tweenProperties[i]; if (abstractTweenProperty.isInitialized) { abstractTweenProperty = abstractTweenProperty.clone(); } addTweenProperty(abstractTweenProperty); } if (base.iterations < 0) { base.totalDuration = float.PositiveInfinity; } else { base.totalDuration = (float)base.iterations * duration; } }
public override bool containsTweenProperty(AbstractTweenProperty property) { for (int i = 0; i < _tweenFlows.Count; i++) { TweenFlowItem tweenFlowItem = _tweenFlows[i]; if (tweenFlowItem.tween != null && tweenFlowItem.tween.containsTweenProperty(property)) { return(true); } } return(false); }
public GoTweenConfig clone() { GoTweenConfig goTweenConfig = MemberwiseClone() as GoTweenConfig; goTweenConfig._tweenProperties = new List <AbstractTweenProperty>(2); for (int i = 0; i < _tweenProperties.Count; i++) { AbstractTweenProperty item = _tweenProperties[i]; goTweenConfig._tweenProperties.Add(item); } return(goTweenConfig); }
/// <summary> /// clones the instance /// </summary> public GoTweenConfig clone() { var other = this.MemberwiseClone() as GoTweenConfig; other._tweenProperties = new List <AbstractTweenProperty>(2); for (int k = 0; k < this._tweenProperties.Count; ++k) { AbstractTweenProperty tweenProp = this._tweenProperties[k]; other._tweenProperties.Add(tweenProp); } return(other); }
public override bool containsTweenProperty( AbstractTweenProperty property ) { foreach( var flowItem in _tweenFlows ) { // skip delay items which have no tween if( flowItem.tween == null ) continue; if( flowItem.tween.containsTweenProperty( property ) ) return true; } return false; }
public void addTweenProperty(AbstractTweenProperty tweenProp) { if (tweenProp.validateTarget(target)) { if (_tweenPropertyList.Contains(tweenProp)) { UnityEngine.Debug.Log("not adding tween property because one already exists: " + tweenProp); return; } _tweenPropertyList.Add(tweenProp); tweenProp.init(this); } else { UnityEngine.Debug.Log("tween failed to validate target: " + tweenProp); } }
public override bool removeTweenProperty(AbstractTweenProperty property) { foreach (var tweenFlowItem in _tweenFlows) { // skip delay items which have no tween if (tweenFlowItem.tween == null) { continue; } if (tweenFlowItem.tween.removeTweenProperty(property)) { return(true); } } return(false); }
public override bool containsTweenProperty(AbstractTweenProperty property) { for (int k = 0; k < _tweenFlows.Count; ++k) { TweenFlowItem flowItem = _tweenFlows[k]; // skip delay items which have no tween if (flowItem.tween == null) { continue; } if (flowItem.tween.containsTweenProperty(property)) { return(true); } } return(false); }
/// <summary> /// checks for duplicate properties. if one is found and the DuplicatePropertyRuleType is set to /// DontAddCurrentProperty it will return true indicating that the tween should not be added. /// this only checks tweens that are not part of an AbstractTweenCollection /// </summary> private bool handleDuplicatePropertiesInTween(GoTween tween) { // first fetch all the current tweens with the same target object as this one var allTweensWithTarget = tweensWithTarget(tween.target); // store a list of all the properties in the tween var allProperties = tween.allTweenProperties(); // TODO: perhaps only perform the check on running Tweens? // loop through all the tweens with the same target for (int k = 0; k < allTweensWithTarget.Count; ++k) { GoTween tweenWithTarget = allTweensWithTarget[k]; // loop through all the properties in the tween and see if there are any dupes for (int z = 0; z < allProperties.Count; ++z) { AbstractTweenProperty tweenProp = allProperties[z]; // check for a matched property if (tweenWithTarget.containsTweenProperty(tweenProp)) { warn("found duplicate TweenProperty {0} in tween {1}", tweenProp, tween); // handle the different duplicate property rules if (duplicatePropertyRule == GoDuplicatePropertyRuleType.DontAddCurrentProperty) { return(true); } else if (duplicatePropertyRule == GoDuplicatePropertyRuleType.RemoveRunningProperty) { // TODO: perhaps check if the Tween has any properties left and remove it if it doesnt? tweenWithTarget.removeTweenProperty(tweenProp); } return(false); } } } return(false); }
/// <summary> /// adds the tween property if it passes validation and initializes the property /// </summary> public void addTweenProperty(AbstractTweenProperty tweenProp) { // make sure the target is valid for this tween before adding if (tweenProp.validateTarget(target)) { // ensure we dont add two tweens of the same property so they dont fight if (_tweenPropertyList.Contains(tweenProp)) { Debug.Log("not adding tween property because one already exists: " + tweenProp); return; } _tweenPropertyList.Add(tweenProp); tweenProp.init(this); } else { Debug.Log("tween failed to validate target: " + tweenProp); } }
/// <summary> /// you can shake any AbstractTweenProperty. /// frameMod allows you to specify what frame count the shakes should occur on. for example, a frameMod of 3 would mean that only when /// frameCount % 3 == 0 will the shake occur /// </summary> public AttenuatedShakeTweenProperty( AbstractTweenProperty tweenPorperty, int frameMod = 1 ) : base(tweenPorperty, (t,b,c,d) => b+Random.Range(-c,c) ,frameMod) { }
/// <summary> /// attempts to remove the tween property returning true if successful /// technically, this should be marked as internal /// </summary> public abstract bool removeTweenProperty(AbstractTweenProperty property);
/// <summary> /// attempts to remove the tween property returning true if successful /// technically, this should be marked as internal /// </summary> public virtual bool removeTweenProperty(AbstractTweenProperty property) { return(false); }
/// <summary> /// returns true if the tween contains the same type (or propertyName) property in its property list /// technically, this should be marked as internal /// </summary> public virtual bool containsTweenProperty(AbstractTweenProperty property) { return(false); }
/// <summary> /// reference another tween property /// </summary> public AbstractDoubleTweenProperty( AbstractTweenProperty tweenPorperty ) : base(true) { _tweenProperty = tweenPorperty; }
/// <summary> /// attempts to remove the tween property returning true if successful /// technically, this should be marked as internal /// </summary> public abstract bool removeTweenProperty( AbstractTweenProperty property );
public override bool removeTweenProperty( AbstractTweenProperty property ) { if( _tweenPropertyList.Contains( property ) ) { _tweenPropertyList.Remove( property ); return true; } return false; }
/// <summary> /// checks for duplicate properties. if one is found and the DuplicatePropertyRuleType is set to /// DontAddCurrentProperty it will return true indicating that the tween should not be added. /// this only checks tweens that are not part of an AbstractTweenCollection /// </summary> private static bool handleDuplicatePropertiesInTween(GoTween tween) { // first fetch all the current tweens with the same target object as this one var allTweensWithTarget = tweensWithTarget(tween.target); // store a list of all the properties in the tween var allProperties = tween.allTweenProperties(); // TODO: perhaps only perform the check on running Tweens? for (int i = 0; allTweensWithTarget.Count > i; i++) { GoTween tweenWithTarget = allTweensWithTarget[i]; for (int j = 0; allProperties.Count > j; j++) { AbstractTweenProperty tweenProp = allProperties[j]; if (tweenWithTarget.containsTweenProperty(tweenProp)) { // handle the different duplicate property rules if (duplicatePropertyRule == GoDuplicatePropertyRuleType.DontAddCurrentProperty) { return(true); } else if (duplicatePropertyRule == GoDuplicatePropertyRuleType.RemoveRunningProperty) { // TODO: perhaps check if the Tween has any properties left and remove it if it doesnt? tweenWithTarget.removeTweenProperty(tweenProp); } return(false); } } } /*// loop through all the tweens with the same target * foreach ( var tweenWithTarget in allTweensWithTarget ) * { * // loop through all the properties in the tween and see if there are any dupes * foreach ( var tweenProp in allProperties ) * { * warn( "found duplicate TweenProperty {0} in tween {1}" , tweenProp , tween ); * * // check for a matched property * if ( tweenWithTarget.containsTweenProperty( tweenProp ) ) * { * // handle the different duplicate property rules * if ( duplicatePropertyRule == GoDuplicatePropertyRuleType.DontAddCurrentProperty ) * { * return true; * } * else if ( duplicatePropertyRule == GoDuplicatePropertyRuleType.RemoveRunningProperty ) * { * // TODO: perhaps check if the Tween has any properties left and remove it if it doesnt? * tweenWithTarget.removeTweenProperty( tweenProp ); * } * * return false; * } * } * }*/ return(false); }
public override bool containsTweenProperty(AbstractTweenProperty property) { return(_tweenPropertyList.Contains(property)); }
/// <summary> /// adds a TweenProperty to the list /// </summary> public TweenConfig addTweenProperty( AbstractTweenProperty tweenProp ) { _tweenProperties.Add( tweenProp ); return this; }
/// <summary> /// you can atenuate any AbstractTweenProperty. /// an attenuated tween property always ends at the same position it started. /// an be for shaking or oscilating a property for example /// frameMod allows you to specify what frame count the shakes should occur on. for example, a frameMod of 3 would mean that only when /// frameCount % 3 == 0 will the shake occur /// </summary> public AttenuatedTweenProperty( AbstractTweenProperty tweenPorperty, Func<float,float,float,float,float> attenuatedEaseFunction, int frameMod = 1 ) : base(tweenPorperty) { _frameMod = frameMod; _attenuatedEaseFunction = attenuatedEaseFunction; }
/// <summary> /// adds a TweenProperty to the list /// </summary> public GoTweenConfig addTweenProperty(AbstractTweenProperty tweenProp) { _tweenProperties.Add(tweenProp); return(this); }
public override bool containsTweenProperty( AbstractTweenProperty property ) { for( int k = 0; k < _tweenFlows.Count; ++k ) { TweenFlowItem flowItem = _tweenFlows[k]; // skip delay items which have no tween if( flowItem.tween == null ) continue; if( flowItem.tween.containsTweenProperty( property ) ) return true; } return false; }
public override bool containsTweenProperty( AbstractTweenProperty property ) { return _tweenPropertyList.Contains( property ); }
/// <summary> /// returns true if the tween contains the same type (or propertyName) property in its /// technically, this should be marked as internal /// property list /// </summary> public abstract bool containsTweenProperty(AbstractTweenProperty property);
/// <summary> /// adds the tween property if it passes validation and initializes the property /// </summary> private void addTweenProperty( AbstractTweenProperty tweenProp ) { // make sure the target is valid for this tween before adding if( tweenProp.validateTarget( target ) ) { // ensure we dont add two tweens of the same property so they dont fight if( _tweenPropertyList.Contains( tweenProp ) ) { Debug.Log( "not adding tween property because one already exists: " + tweenProp ); return; } _tweenPropertyList.Add( tweenProp ); tweenProp.init( this ); } else { Debug.Log( "tween failed to validate target: " + tweenProp ); } }
/// <summary> /// you can oscilate any AbstractTweenProperty. /// frameMod allows you to specify what frame count the shakes should occur on. for example, a frameMod of 3 would mean that only when /// frameCount % 3 == 0 will the shake occur /// </summary> public AttenuatedOscillateTweenProperty( AbstractTweenProperty tweenPorperty, float period, int frameMod = 1 ) : base(tweenPorperty, (t,b,c,d) => b+c*Mathf.Sin(t*2*Mathf.PI/period) ,frameMod) { }
/// <summary> /// returns true if the tween contains the same type (or propertyName) property in its /// technically, this should be marked as internal /// property list /// </summary> public abstract bool containsTweenProperty( AbstractTweenProperty property );
public override bool containsTweenProperty ( AbstractTweenProperty property ) { for ( int i = 0 ; _tweenFlows.Count > i ; i++ ) { // skip delay items which have no tween if ( _tweenFlows[ i ].tween == null ) continue; if ( _tweenFlows[ i ].tween.containsTweenProperty( property ) ) return true; } /*foreach ( var flowItem in _tweenFlows ) { // skip delay items which have no tween if ( flowItem.tween == null ) continue; if ( flowItem.tween.containsTweenProperty( property ) ) return true; }*/ return false; }