From 6f21e1dd44ce2567b30420854bc9f206797e3f6c Mon Sep 17 00:00:00 2001 From: Jean-Philippe SARDA Date: Mon, 30 Sep 2013 23:57:44 +0200 Subject: [PATCH 1/3] =?UTF-8?q?Added=20a=20ShakeGenericTweenProperty=20cla?= =?UTF-8?q?ss=20to=20allow=20shaking=20any=20kind=20of=20AbstractTweenProp?= =?UTF-8?q?erty=20(floats,=20ints,=20Vector2,=20etc=E2=80=A6).=20Added=20c?= =?UTF-8?q?orresponding=20entries=20in=20GoTweenConfig=20(=20shakeFloatPro?= =?UTF-8?q?p,=20intFloatProp,=20etc=E2=80=A6).?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Assets/Plugins/GoKit/GoTweenConfig.cs | 133 ++++++++++++++++++ .../ShakeGenericTweenProperty.cs | 74 ++++++++++ 2 files changed, 207 insertions(+) create mode 100644 Assets/Plugins/GoKit/properties/specificTypes/ShakeGenericTweenProperty.cs diff --git a/Assets/Plugins/GoKit/GoTweenConfig.cs b/Assets/Plugins/GoKit/GoTweenConfig.cs index fae96f6..589a63b 100644 --- a/Assets/Plugins/GoKit/GoTweenConfig.cs +++ b/Assets/Plugins/GoKit/GoTweenConfig.cs @@ -310,6 +310,139 @@ public GoTweenConfig floatProp( string propertyName, float endValue, bool isRela return this; } + #endregion + + #region shake generic properties + + /// + /// shake generic vector2 tween + /// + public GoTweenConfig shakeVector2Prop( string propertyName, Vector2 endValue, bool isRelative = true, int frameMod = 1 ) + { + var genericProp = new Vector2TweenProperty( propertyName, endValue, isRelative ); + var prop = new ShakeGenericTweenProperty( genericProp, frameMod ); + _tweenProperties.Add( prop ); + + return this; + } + + + /// + /// shake generic vector3 tween + /// + public GoTweenConfig shakeVector3Prop( string propertyName, Vector3 endValue, bool isRelative = true, int frameMod = 1 ) + { + var genericProp = new Vector3TweenProperty( propertyName, endValue, isRelative ); + var prop = new ShakeGenericTweenProperty( genericProp, frameMod ); + _tweenProperties.Add( prop ); + + return this; + } + + + /// + /// shake generic vector4 tween + /// + public GoTweenConfig shakeVector4Prop( string propertyName, Vector4 endValue, bool isRelative = true, int frameMod = 1 ) + { + var genericProp = new Vector4TweenProperty( propertyName, endValue, isRelative ); + var prop = new ShakeGenericTweenProperty( genericProp, frameMod ); + _tweenProperties.Add( prop ); + + return this; + } + + + /// + /// shake generic vector3 path tween + /// + public GoTweenConfig shakeVector3PathProp( string propertyName, GoSpline path, bool isRelative = true, int frameMod = 1 ) + { + var genericProp = new Vector3PathTweenProperty( propertyName, path, isRelative ); + var prop = new ShakeGenericTweenProperty( genericProp, frameMod ); + _tweenProperties.Add( prop ); + + return this; + } + + + /// + /// shake generic vector3.x tween + /// + public GoTweenConfig shakeVector3XProp( string propertyName, float endValue, bool isRelative = true, int frameMod = 1 ) + { + var genericProp = new Vector3XTweenProperty( propertyName, endValue, isRelative ); + var prop = new ShakeGenericTweenProperty( genericProp, frameMod ); + _tweenProperties.Add( prop ); + + return this; + } + + + /// + /// shake generic vector3.y tween + /// + public GoTweenConfig shakeVector3YProp( string propertyName, float endValue, bool isRelative = true, int frameMod = 1 ) + { + var genericProp = new Vector3YTweenProperty( propertyName, endValue, isRelative ); + var prop = new ShakeGenericTweenProperty( genericProp, frameMod ); + _tweenProperties.Add( prop ); + + return this; + } + + + /// + /// shake generic vector3.z tween + /// + public GoTweenConfig shakeVector3ZProp( string propertyName, float endValue, bool isRelative = true, int frameMod = 1 ) + { + var genericProp = new Vector3ZTweenProperty( propertyName, endValue, isRelative ); + var prop = new ShakeGenericTweenProperty( genericProp, frameMod ); + _tweenProperties.Add( prop ); + + return this; + } + + + /// + /// shake generic color tween + /// + public GoTweenConfig shakeColorProp( string propertyName, Color endValue, bool isRelative = true, int frameMod = 1 ) + { + var genericProp = new ColorTweenProperty( propertyName, endValue, isRelative ); + var prop = new ShakeGenericTweenProperty( genericProp, frameMod ); + _tweenProperties.Add( prop ); + + return this; + } + + + /// + /// shake generic integer tween + /// + public GoTweenConfig shakeIntProp( string propertyName, int endValue, bool isRelative = true, int frameMod = 1 ) + { + var genericProp = new IntTweenProperty( propertyName, endValue, isRelative ); + var prop = new ShakeGenericTweenProperty( genericProp, frameMod ); + _tweenProperties.Add( prop ); + + return this; + } + + + /// + /// shake generic float tween + /// + public GoTweenConfig shakeFloatProp( string propertyName, float endValue, bool isRelative = true, int frameMod = 1 ) + { + var genericProp = new FloatTweenProperty( propertyName, endValue, isRelative ); + var prop = new ShakeGenericTweenProperty( genericProp, frameMod ); + _tweenProperties.Add( prop ); + + return this; + } + #endregion #endregion diff --git a/Assets/Plugins/GoKit/properties/specificTypes/ShakeGenericTweenProperty.cs b/Assets/Plugins/GoKit/properties/specificTypes/ShakeGenericTweenProperty.cs new file mode 100644 index 0000000..c3ba05c --- /dev/null +++ b/Assets/Plugins/GoKit/properties/specificTypes/ShakeGenericTweenProperty.cs @@ -0,0 +1,74 @@ +using UnityEngine; +using System.Collections; + + +public class ShakeGenericTweenProperty : AbstractTweenProperty +{ + private AbstractTweenProperty _tweenProperty; + + private int _frameCount; + private int _frameMod; + + + /// + /// 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 + /// + public ShakeGenericTweenProperty( AbstractTweenProperty tweenPorperty, int frameMod = 1 ) : base( true ) + { + _tweenProperty = tweenPorperty; + _frameMod = frameMod; + } + + + #region Object overrides + + public override int GetHashCode() + { + return base.GetHashCode(); + } + + + public override bool Equals( object obj ) + { + // start with a base check and then compare our material names + return _tweenProperty.Equals(((ShakeGenericTweenProperty)obj)._tweenProperty); + } + + #endregion + + public override void init( GoTween owner ) + { + base.init(owner); + //Init owner of _tweenProperty and force ease type to linear + _tweenProperty.setEaseType(GoEaseType.Linear); + _tweenProperty.init(owner); + } + + public override bool validateTarget( object target ) + { + return _tweenProperty.validateTarget(target); + } + + + public override void prepareForUse() + { + _tweenProperty.prepareForUse(); + _frameCount = 0; + } + + + public override void tick( float totalElapsedTime ) + { + // should we skip any frames? + if( _frameMod > 1 && ++_frameCount % _frameMod != 0 ) + return; + + // _ownerTween is supposed to have a GoEaseLinear easeType + float timeLimit=_ownerTween.duration-_easeFunction(totalElapsedTime, 0, _ownerTween.duration, _ownerTween.duration); + var randomTime=Random.Range(-timeLimit,timeLimit); + + _tweenProperty.tick(randomTime); + } +} From 46f6f138b3aa00262f5abf3ced354f720f482898 Mon Sep 17 00:00:00 2001 From: Jean-Philippe SARDA Date: Tue, 1 Oct 2013 11:48:22 +0200 Subject: [PATCH 2/3] Created a more generic AttenuatedTweenProperty that can be used for shaking, oscillating, and more. Created new folder attenuated in properties Moved and renamed ShakeGenericTweenProperty into attenuated/AttenuatedShakeTweenProperty Created AttenuatedOscillateTweenProperty and all necessary entries in GoTweenConfig --- Assets/Plugins/GoKit/GoTweenConfig.cs | 155 ++++++++++++++++-- .../abstracts/AbstractDoubleTweenProperty.cs | 52 ++++++ .../AttenuatedOscillateTweenProperty.cs | 18 ++ .../AttenuatedShakeTweenProperty.cs | 18 ++ .../attenuated/AttenuatedTweenProperty.cs | 59 +++++++ .../ShakeGenericTweenProperty.cs | 74 --------- 6 files changed, 291 insertions(+), 85 deletions(-) create mode 100644 Assets/Plugins/GoKit/properties/abstracts/AbstractDoubleTweenProperty.cs create mode 100644 Assets/Plugins/GoKit/properties/attenuated/AttenuatedOscillateTweenProperty.cs create mode 100644 Assets/Plugins/GoKit/properties/attenuated/AttenuatedShakeTweenProperty.cs create mode 100644 Assets/Plugins/GoKit/properties/attenuated/AttenuatedTweenProperty.cs delete mode 100644 Assets/Plugins/GoKit/properties/specificTypes/ShakeGenericTweenProperty.cs diff --git a/Assets/Plugins/GoKit/GoTweenConfig.cs b/Assets/Plugins/GoKit/GoTweenConfig.cs index 589a63b..0dcf06f 100644 --- a/Assets/Plugins/GoKit/GoTweenConfig.cs +++ b/Assets/Plugins/GoKit/GoTweenConfig.cs @@ -312,7 +312,7 @@ public GoTweenConfig floatProp( string propertyName, float endValue, bool isRela #endregion - #region shake generic properties + #region attenuated shake generic properties /// /// shake generic vector2 tween @@ -320,7 +320,7 @@ public GoTweenConfig floatProp( string propertyName, float endValue, bool isRela public GoTweenConfig shakeVector2Prop( string propertyName, Vector2 endValue, bool isRelative = true, int frameMod = 1 ) { var genericProp = new Vector2TweenProperty( propertyName, endValue, isRelative ); - var prop = new ShakeGenericTweenProperty( genericProp, frameMod ); + var prop = new AttenuatedShakeTweenProperty( genericProp, frameMod ); _tweenProperties.Add( prop ); return this; @@ -333,7 +333,7 @@ public GoTweenConfig shakeVector2Prop( string propertyName, Vector2 endValue, bo public GoTweenConfig shakeVector3Prop( string propertyName, Vector3 endValue, bool isRelative = true, int frameMod = 1 ) { var genericProp = new Vector3TweenProperty( propertyName, endValue, isRelative ); - var prop = new ShakeGenericTweenProperty( genericProp, frameMod ); + var prop = new AttenuatedShakeTweenProperty( genericProp, frameMod ); _tweenProperties.Add( prop ); return this; @@ -346,7 +346,7 @@ public GoTweenConfig shakeVector3Prop( string propertyName, Vector3 endValue, bo public GoTweenConfig shakeVector4Prop( string propertyName, Vector4 endValue, bool isRelative = true, int frameMod = 1 ) { var genericProp = new Vector4TweenProperty( propertyName, endValue, isRelative ); - var prop = new ShakeGenericTweenProperty( genericProp, frameMod ); + var prop = new AttenuatedShakeTweenProperty( genericProp, frameMod ); _tweenProperties.Add( prop ); return this; @@ -359,7 +359,7 @@ public GoTweenConfig shakeVector4Prop( string propertyName, Vector4 endValue, bo public GoTweenConfig shakeVector3PathProp( string propertyName, GoSpline path, bool isRelative = true, int frameMod = 1 ) { var genericProp = new Vector3PathTweenProperty( propertyName, path, isRelative ); - var prop = new ShakeGenericTweenProperty( genericProp, frameMod ); + var prop = new AttenuatedShakeTweenProperty( genericProp, frameMod ); _tweenProperties.Add( prop ); return this; @@ -372,7 +372,7 @@ public GoTweenConfig shakeVector3PathProp( string propertyName, GoSpline path, b public GoTweenConfig shakeVector3XProp( string propertyName, float endValue, bool isRelative = true, int frameMod = 1 ) { var genericProp = new Vector3XTweenProperty( propertyName, endValue, isRelative ); - var prop = new ShakeGenericTweenProperty( genericProp, frameMod ); + var prop = new AttenuatedShakeTweenProperty( genericProp, frameMod ); _tweenProperties.Add( prop ); return this; @@ -385,7 +385,7 @@ public GoTweenConfig shakeVector3XProp( string propertyName, float endValue, boo public GoTweenConfig shakeVector3YProp( string propertyName, float endValue, bool isRelative = true, int frameMod = 1 ) { var genericProp = new Vector3YTweenProperty( propertyName, endValue, isRelative ); - var prop = new ShakeGenericTweenProperty( genericProp, frameMod ); + var prop = new AttenuatedShakeTweenProperty( genericProp, frameMod ); _tweenProperties.Add( prop ); return this; @@ -398,7 +398,7 @@ public GoTweenConfig shakeVector3YProp( string propertyName, float endValue, boo public GoTweenConfig shakeVector3ZProp( string propertyName, float endValue, bool isRelative = true, int frameMod = 1 ) { var genericProp = new Vector3ZTweenProperty( propertyName, endValue, isRelative ); - var prop = new ShakeGenericTweenProperty( genericProp, frameMod ); + var prop = new AttenuatedShakeTweenProperty( genericProp, frameMod ); _tweenProperties.Add( prop ); return this; @@ -411,7 +411,7 @@ public GoTweenConfig shakeVector3ZProp( string propertyName, float endValue, boo public GoTweenConfig shakeColorProp( string propertyName, Color endValue, bool isRelative = true, int frameMod = 1 ) { var genericProp = new ColorTweenProperty( propertyName, endValue, isRelative ); - var prop = new ShakeGenericTweenProperty( genericProp, frameMod ); + var prop = new AttenuatedShakeTweenProperty( genericProp, frameMod ); _tweenProperties.Add( prop ); return this; @@ -424,7 +424,7 @@ public GoTweenConfig shakeColorProp( string propertyName, Color endValue, bool i public GoTweenConfig shakeIntProp( string propertyName, int endValue, bool isRelative = true, int frameMod = 1 ) { var genericProp = new IntTweenProperty( propertyName, endValue, isRelative ); - var prop = new ShakeGenericTweenProperty( genericProp, frameMod ); + var prop = new AttenuatedShakeTweenProperty( genericProp, frameMod ); _tweenProperties.Add( prop ); return this; @@ -437,7 +437,140 @@ public GoTweenConfig shakeIntProp( string propertyName, int endValue, bool isRel public GoTweenConfig shakeFloatProp( string propertyName, float endValue, bool isRelative = true, int frameMod = 1 ) { var genericProp = new FloatTweenProperty( propertyName, endValue, isRelative ); - var prop = new ShakeGenericTweenProperty( genericProp, frameMod ); + var prop = new AttenuatedShakeTweenProperty( genericProp, frameMod ); + _tweenProperties.Add( prop ); + + return this; + } + + #endregion + + #region attenuated oscillate generic properties + + /// + /// oscillate generic vector2 tween + /// + public GoTweenConfig oscillateVector2Prop( string propertyName, Vector2 endValue, float period, bool isRelative = true, int frameMod = 1 ) + { + var genericProp = new Vector2TweenProperty( propertyName, endValue, isRelative ); + var prop = new AttenuatedOscillateTweenProperty( genericProp, period, frameMod ); + _tweenProperties.Add( prop ); + + return this; + } + + + /// + /// oscillate generic vector3 tween + /// + public GoTweenConfig oscillateVector3Prop( string propertyName, Vector3 endValue, float period, bool isRelative = true, int frameMod = 1 ) + { + var genericProp = new Vector3TweenProperty( propertyName, endValue, isRelative ); + var prop = new AttenuatedOscillateTweenProperty( genericProp, period, frameMod ); + _tweenProperties.Add( prop ); + + return this; + } + + + /// + /// oscillate generic vector4 tween + /// + public GoTweenConfig oscillateVector4Prop( string propertyName, Vector4 endValue, float period, bool isRelative = true, int frameMod = 1 ) + { + var genericProp = new Vector4TweenProperty( propertyName, endValue, isRelative ); + var prop = new AttenuatedOscillateTweenProperty( genericProp, period, frameMod ); + _tweenProperties.Add( prop ); + + return this; + } + + + /// + /// oscillate generic vector3 path tween + /// + public GoTweenConfig oscillateVector3PathProp( string propertyName, GoSpline path, float period, bool isRelative = true, int frameMod = 1 ) + { + var genericProp = new Vector3PathTweenProperty( propertyName, path, isRelative ); + var prop = new AttenuatedOscillateTweenProperty( genericProp, period, frameMod ); + _tweenProperties.Add( prop ); + + return this; + } + + + /// + /// oscillate generic vector3.x tween + /// + public GoTweenConfig oscillateVector3XProp( string propertyName, float endValue, float period, bool isRelative = true, int frameMod = 1 ) + { + var genericProp = new Vector3XTweenProperty( propertyName, endValue, isRelative ); + var prop = new AttenuatedOscillateTweenProperty( genericProp, period, frameMod ); + _tweenProperties.Add( prop ); + + return this; + } + + + /// + /// oscillate generic vector3.y tween + /// + public GoTweenConfig oscillateVector3YProp( string propertyName, float endValue, float period, bool isRelative = true, int frameMod = 1 ) + { + var genericProp = new Vector3YTweenProperty( propertyName, endValue, isRelative ); + var prop = new AttenuatedOscillateTweenProperty( genericProp, period, frameMod ); + _tweenProperties.Add( prop ); + + return this; + } + + + /// + /// oscillate generic vector3.z tween + /// + public GoTweenConfig oscillateVector3ZProp( string propertyName, float endValue, float period, bool isRelative = true, int frameMod = 1 ) + { + var genericProp = new Vector3ZTweenProperty( propertyName, endValue, isRelative ); + var prop = new AttenuatedOscillateTweenProperty( genericProp, period, frameMod ); + _tweenProperties.Add( prop ); + + return this; + } + + + /// + /// oscillate generic color tween + /// + public GoTweenConfig oscillateColorProp( string propertyName, Color endValue, float period, bool isRelative = true, int frameMod = 1 ) + { + var genericProp = new ColorTweenProperty( propertyName, endValue, isRelative ); + var prop = new AttenuatedOscillateTweenProperty( genericProp, period, frameMod ); + _tweenProperties.Add( prop ); + + return this; + } + + + /// + /// oscillate generic integer tween + /// + public GoTweenConfig oscillateIntProp( string propertyName, int endValue, float period, bool isRelative = true, int frameMod = 1 ) + { + var genericProp = new IntTweenProperty( propertyName, endValue, isRelative ); + var prop = new AttenuatedOscillateTweenProperty( genericProp, period, frameMod ); + _tweenProperties.Add( prop ); + + return this; + } + + + /// + /// oscillate generic float tween + /// + public GoTweenConfig oscillateFloatProp( string propertyName, float endValue, float period, bool isRelative = true, int frameMod = 1 ) + { + var genericProp = new FloatTweenProperty( propertyName, endValue, isRelative ); + var prop = new AttenuatedOscillateTweenProperty( genericProp, period, frameMod ); _tweenProperties.Add( prop ); return this; diff --git a/Assets/Plugins/GoKit/properties/abstracts/AbstractDoubleTweenProperty.cs b/Assets/Plugins/GoKit/properties/abstracts/AbstractDoubleTweenProperty.cs new file mode 100644 index 0000000..b07caeb --- /dev/null +++ b/Assets/Plugins/GoKit/properties/abstracts/AbstractDoubleTweenProperty.cs @@ -0,0 +1,52 @@ +using UnityEngine; +using System.Collections; + + +public abstract class AbstractDoubleTweenProperty : AbstractTweenProperty +{ + protected AbstractTweenProperty _tweenProperty; + + /// + /// reference another tween property + /// + public AbstractDoubleTweenProperty( AbstractTweenProperty tweenPorperty ) : base( true ) + { + _tweenProperty = tweenPorperty; + } + + + #region Object overrides + + public override int GetHashCode() + { + return base.GetHashCode(); + } + + + public override bool Equals( object obj ) + { + // start with a base check and then compare our material names + return _tweenProperty.Equals(((AbstractDoubleTweenProperty)obj)._tweenProperty); + } + + #endregion + + public override void init( GoTween owner ) + { + base.init(owner); + //Init owner of _tweenProperty and force ease type to linear + _tweenProperty.setEaseType(GoEaseType.Linear); + _tweenProperty.init(owner); + } + + public override bool validateTarget( object target ) + { + return _tweenProperty.validateTarget(target); + } + + + public override void prepareForUse() + { + _tweenProperty.prepareForUse(); + } +} diff --git a/Assets/Plugins/GoKit/properties/attenuated/AttenuatedOscillateTweenProperty.cs b/Assets/Plugins/GoKit/properties/attenuated/AttenuatedOscillateTweenProperty.cs new file mode 100644 index 0000000..763c4a7 --- /dev/null +++ b/Assets/Plugins/GoKit/properties/attenuated/AttenuatedOscillateTweenProperty.cs @@ -0,0 +1,18 @@ +using UnityEngine; +using System.Collections; + + + +public class AttenuatedOscillateTweenProperty : AttenuatedTweenProperty +{ + + /// + /// 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 + /// + 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 ) + { + } +} + diff --git a/Assets/Plugins/GoKit/properties/attenuated/AttenuatedShakeTweenProperty.cs b/Assets/Plugins/GoKit/properties/attenuated/AttenuatedShakeTweenProperty.cs new file mode 100644 index 0000000..2a3e006 --- /dev/null +++ b/Assets/Plugins/GoKit/properties/attenuated/AttenuatedShakeTweenProperty.cs @@ -0,0 +1,18 @@ +using UnityEngine; +using System.Collections; + + + +public class AttenuatedShakeTweenProperty : AttenuatedTweenProperty +{ + + /// + /// 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 + /// + public AttenuatedShakeTweenProperty( AbstractTweenProperty tweenPorperty, int frameMod = 1 ) : base( tweenPorperty, (t,b,c,d) => b+Random.Range(-c,c) ,frameMod ) + { + } +} + diff --git a/Assets/Plugins/GoKit/properties/attenuated/AttenuatedTweenProperty.cs b/Assets/Plugins/GoKit/properties/attenuated/AttenuatedTweenProperty.cs new file mode 100644 index 0000000..8117026 --- /dev/null +++ b/Assets/Plugins/GoKit/properties/attenuated/AttenuatedTweenProperty.cs @@ -0,0 +1,59 @@ +using UnityEngine; +using System; +using System.Collections; +using System.Reflection; + + +public class AttenuatedTweenProperty : AbstractDoubleTweenProperty +{ + protected int _frameCount; + protected int _frameMod; + protected Func _attenuatedEaseFunction; + + + /// + /// 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 + /// + public AttenuatedTweenProperty( AbstractTweenProperty tweenPorperty, Func attenuatedEaseFunction, int frameMod = 1 ) : base( tweenPorperty ) + { + _frameMod = frameMod; + _attenuatedEaseFunction = attenuatedEaseFunction; + } + + + #region Object overrides + + public override int GetHashCode() + { + return base.GetHashCode(); + } + + #endregion + + public override void prepareForUse() + { + base.prepareForUse(); + _frameCount = 0; + } + + + public override void tick( float totalElapsedTime ) + { + // should we skip any frames? + if( _frameMod > 1 && ++_frameCount % _frameMod != 0 ) + return; + + // _ownerTween is supposed to have a GoEaseLinear easeType + // in this case _easeFunction is just used to attenuated the _attenuatedEaseFunction + // _attenuatedEaseFunction contains the main effect (oscillation, shake, etc...) + + var attenuatedElapsedTime=_ownerTween.duration-_easeFunction(totalElapsedTime, 0, _ownerTween.duration, _ownerTween.duration); + var easedTime=_attenuatedEaseFunction(totalElapsedTime,0f,attenuatedElapsedTime,_ownerTween.duration); + + _tweenProperty.tick(easedTime); + } +} diff --git a/Assets/Plugins/GoKit/properties/specificTypes/ShakeGenericTweenProperty.cs b/Assets/Plugins/GoKit/properties/specificTypes/ShakeGenericTweenProperty.cs deleted file mode 100644 index c3ba05c..0000000 --- a/Assets/Plugins/GoKit/properties/specificTypes/ShakeGenericTweenProperty.cs +++ /dev/null @@ -1,74 +0,0 @@ -using UnityEngine; -using System.Collections; - - -public class ShakeGenericTweenProperty : AbstractTweenProperty -{ - private AbstractTweenProperty _tweenProperty; - - private int _frameCount; - private int _frameMod; - - - /// - /// 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 - /// - public ShakeGenericTweenProperty( AbstractTweenProperty tweenPorperty, int frameMod = 1 ) : base( true ) - { - _tweenProperty = tweenPorperty; - _frameMod = frameMod; - } - - - #region Object overrides - - public override int GetHashCode() - { - return base.GetHashCode(); - } - - - public override bool Equals( object obj ) - { - // start with a base check and then compare our material names - return _tweenProperty.Equals(((ShakeGenericTweenProperty)obj)._tweenProperty); - } - - #endregion - - public override void init( GoTween owner ) - { - base.init(owner); - //Init owner of _tweenProperty and force ease type to linear - _tweenProperty.setEaseType(GoEaseType.Linear); - _tweenProperty.init(owner); - } - - public override bool validateTarget( object target ) - { - return _tweenProperty.validateTarget(target); - } - - - public override void prepareForUse() - { - _tweenProperty.prepareForUse(); - _frameCount = 0; - } - - - public override void tick( float totalElapsedTime ) - { - // should we skip any frames? - if( _frameMod > 1 && ++_frameCount % _frameMod != 0 ) - return; - - // _ownerTween is supposed to have a GoEaseLinear easeType - float timeLimit=_ownerTween.duration-_easeFunction(totalElapsedTime, 0, _ownerTween.duration, _ownerTween.duration); - var randomTime=Random.Range(-timeLimit,timeLimit); - - _tweenProperty.tick(randomTime); - } -} From 0422b1afe5713fcebd26becceafaa66d4d5255d2 Mon Sep 17 00:00:00 2001 From: Jean-Philippe SARDA Date: Tue, 1 Oct 2013 16:16:02 +0200 Subject: [PATCH 3/3] Fixed Equals(obj) in AbstractDoubleTweenProperty --- .../properties/abstracts/AbstractDoubleTweenProperty.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Assets/Plugins/GoKit/properties/abstracts/AbstractDoubleTweenProperty.cs b/Assets/Plugins/GoKit/properties/abstracts/AbstractDoubleTweenProperty.cs index b07caeb..675ac66 100644 --- a/Assets/Plugins/GoKit/properties/abstracts/AbstractDoubleTweenProperty.cs +++ b/Assets/Plugins/GoKit/properties/abstracts/AbstractDoubleTweenProperty.cs @@ -25,8 +25,10 @@ public override int GetHashCode() public override bool Equals( object obj ) { - // start with a base check and then compare our material names - return _tweenProperty.Equals(((AbstractDoubleTweenProperty)obj)._tweenProperty); + if (base.Equals(obj)) { + return _tweenProperty.Equals(((AbstractDoubleTweenProperty)obj)._tweenProperty); + } + return false; } #endregion