Exemple #1
0
    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;
                }
            });
        }
    }
Exemple #2
0
 public static IEnumerator WaitForPositionTween(this Tween t, float position)
 {
     while (t.active && t.position * (t.CompletedLoops() + 1) < position)
     {
         yield return(null);
     }
 }
Exemple #3
0
 public static IEnumerator WaitForElapsedLoopTween(this Tween t, int elapsedLoops)
 {
     while (t.active && t.CompletedLoops() < elapsedLoops)
     {
         yield return(null);
     }
 }
Exemple #4
0
 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);
    }
Exemple #9
0
 public int GetCurrentLoop()
 {
     return(m.CompletedLoops());
 }
Exemple #10
0
 /// <summary>
 /// Completeds the loops.
 /// </summary>
 /// <returns>The loops.</returns>
 public int CompletedLoops()
 {
     return(tween.CompletedLoops());
 }