public void HandleJump(bool sweetSpot) { if (fenceJumpTween == null) { float delay = 0f; if (!sweetSpot) { delay = Random.Range(0f, 2f); } fenceJumpTween = transform.DOLocalMoveY(transform.localPosition.y + (WALK_SPEED / 2f), 0.75f).SetLoops(2, LoopType.Yoyo).SetDelay(delay).SetEase(Ease.InOutCirc); fenceJumpTween.OnStepComplete(() => { if (fenceJumpTween.CompletedLoops() == 1) { if (!sweetSpot) { int jumpNow = Random.Range(0, 3); if (jumpNow == 0) { SoundManager.instance.PlaySingle(SoundManager.instance.jumpFence, 0.25f); } } } if (fenceJumpTween.CompletedLoops() > 1) { fenceJumpTween = null; } }); } }
public static IEnumerator WaitForPositionTween(this Tween t, float position) { while (t.active && t.position * (t.CompletedLoops() + 1) < position) { yield return(null); } }
public static IEnumerator WaitForElapsedLoopTween(this Tween t, int elapsedLoops) { while (t.active && t.CompletedLoops() < elapsedLoops) { yield return(null); } }
public static IEnumerator WaitForRewindTween(this Tween t) { while (t.active && (!t.playedOnce || t.position * (t.CompletedLoops() + 1) > 0.0)) { yield return(null); } }
/// <summary> /// Returns an async <see cref="Task"/> that waits until the tween is killed or started /// (meaning when the tween is set in a playing state the first time, after any eventual delay). /// It can be used inside an async operation. /// <para>Example usage:</para><code>await myTween.AsyncWaitForPosition();</code> /// </summary> /// <param name="position">Position (loops included, delays excluded) to wait for</param> public static async Task AsyncWaitForPosition(this Tween t, float position) { if (!t.active) { if (Debugger.logPriority > 0) { Debugger.LogInvalidTween(t); } return; } while (t.active && t.position * (t.CompletedLoops() + 1) < position) { await Task.Yield(); } }
/// <summary> /// Returns an async <see cref="Task"/> that waits until the tween is killed or has gone through the given amount of loops. /// It can be used inside an async operation. /// <para>Example usage:</para><code>await myTween.AsyncWaitForElapsedLoops();</code> /// </summary> /// <param name="elapsedLoops">Elapsed loops to wait for</param> public static async Task AsyncWaitForElapsedLoops(this Tween t, int elapsedLoops) { if (!t.active) { if (Debugger.logPriority > 0) { Debugger.LogInvalidTween(t); } return; } while (t.active && t.CompletedLoops() < elapsedLoops) { await Task.Yield(); } }
/// <summary> /// Returns an async <see cref="Task"/> that waits until the tween is killed or rewinded. /// It can be used inside an async operation. /// <para>Example usage:</para><code>await myTween.AsyncWaitForRewind();</code> /// </summary> public static async Task AsyncWaitForRewind(this Tween t) { if (!t.active) { if (Debugger.logPriority > 0) { Debugger.LogInvalidTween(t); } return; } while (t.active && (!t.playedOnce || t.position * (t.CompletedLoops() + 1) > 0)) { await Task.Yield(); } }
private static int CompletedLoops(IntPtr L) { int result; try { ToLua.CheckArgsCount(L, 1); Tween t = (Tween)ToLua.CheckObject(L, 1, typeof(Tween)); int n = t.CompletedLoops(); LuaDLL.lua_pushinteger(L, n); result = 1; } catch (Exception e) { result = LuaDLL.toluaL_exception(L, e, null); } return(result); }
public int GetCurrentLoop() { return(m.CompletedLoops()); }
/// <summary> /// Completeds the loops. /// </summary> /// <returns>The loops.</returns> public int CompletedLoops() { return(tween.CompletedLoops()); }