Skip to content

Commit ec39496

Browse files
committed
fix(Effect): Handle pause in 3d shake
1 parent 52d2c49 commit ec39496

File tree

2 files changed

+21
-15
lines changed

2 files changed

+21
-15
lines changed

Assets/JCSUnity/Scripts/Effects/3D/JCS_3DShakeEffect.cs

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,9 @@ public class JCS_3DShakeEffect : JCS_UnityObject
4848
[SerializeField]
4949
private JCS_TransformType mTransformType = JCS_TransformType.POSITION;
5050

51-
[Tooltip("Override the effect even the the effect is enabled already.")]
51+
[Tooltip("Force the effect even when its already in the motion.")]
5252
[SerializeField]
53-
private bool mRepeatOverride = false;
53+
private bool mForce = false;
5454

5555
[Tooltip("How long it shakes.")]
5656
[SerializeField]
@@ -101,7 +101,7 @@ public class JCS_3DShakeEffect : JCS_UnityObject
101101
public bool Effect { get { return this.mEffect; } set { this.mEffect = value; } }
102102

103103
public JCS_TransformType TransformType { get { return this.mTransformType; } set { this.mTransformType = value; } }
104-
public bool RepeatOverride { get { return this.mRepeatOverride; } set { this.mRepeatOverride = value; } }
104+
public bool Force { get { return this.mForce; } set { this.mForce = value; } }
105105
public float ShakeTime { get { return this.mShakeTime; } set { this.mShakeTime = value; } }
106106
public float ShakeMargin { get { return this.mShakeMargin; } }
107107
public float ShakeSteps { get { return this.mShakeSteps; } set { this.mShakeSteps = value; } }
@@ -139,22 +139,18 @@ private void Test()
139139
}
140140
#endif
141141

142-
/// <summary>
143-
/// Do the shake with default shake time and shake margin.
144-
/// </summary>
145-
public void DoShake()
146-
{
147-
DoShake(mShakeTime, mShakeMargin);
148-
}
149-
150142
/// <summary>
151143
/// Do the shake effect with time and margin.
152144
/// </summary>
153145
/// <param name="time"> time to do the shake. </param>
154146
/// <param name="margin"> margin to do the shake. </param>
155-
public void DoShake(float time, float margin)
147+
public void DoShake()
156148
{
157-
if (!mRepeatOverride)
149+
DoShake(mShakeTime, mShakeMargin, mForce);
150+
}
151+
public void DoShake(float time, float margin, bool force)
152+
{
153+
if (!force)
158154
{
159155
// if is doing the effect
160156
if (mEffect)
@@ -187,7 +183,17 @@ private void DoEffect()
187183

188184
mShakeDelta = Vector3.zero;
189185

190-
mShakeTimer += JCS_Time.ItTime(mTimeType);
186+
float dt = JCS_Time.ItTime(mTimeType);
187+
188+
// Handle pause situation.
189+
{
190+
var pm = JCS_PauseManager.instance;
191+
192+
if (pm != null && pm.Paused)
193+
return;
194+
}
195+
196+
mShakeTimer += dt;
191197

192198
if (mShakeTimer < mShakeTime)
193199
{

docs/ScriptReference/Effects/3D/JCS_3DShakeEffect.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Effect that shake the transform in 3D.
77
| Name | Description |
88
|:---------------|:-----------------------------------------------------------|
99
| TransformType | Shake on this transform properties. |
10-
| RepeatOverride | Override the effect even when the effect is already taken. |
10+
| Firce | Force the effect even when its already in the motion. |
1111
| ShakeTime | How long it shakes. |
1212
| ShakeMargin | How intense it shakes. |
1313
| mTimeType | Type of the delta time. |

0 commit comments

Comments
 (0)