Exemplo n.º 1
0
        private void DoAnimation()
        {
            if (evaluatorHandler == null || evaluatorHandler.Invoke())
            {
                OnAnimationCompleted();
            }
            else
            {
                actionHandler.Invoke();
                counter++;

                timer.Start();
            }
        }
Exemplo n.º 2
0
    /// <summary>
    /// The method provides a simple mechanism for code based animations
    /// </summary>
    /// <param name="duration">Animation's duration</param>
    /// <param name="action">An action should be executed</param>
    /// <returns>A reference to enumerator</returns>

    public static IEnumerator Animate(float duration, AnimationAction action, UnityAction postAction = null)
    {
        if (action == null)
        {
            yield break;
        }

        float dt = 0.0f;

        for (float time = 0.0f; Mathf.Abs(time - duration) > (dt = Time.deltaTime); time += dt)
        {
            action?.Invoke(time);

            yield return(null);
        }

        postAction?.Invoke();

        yield return(null);
    }
Exemplo n.º 3
0
 public void AnimationStart()
 {
     animationStartAction.Invoke();
 }
Exemplo n.º 4
0
 public void AnimationEnd()
 {
     animationEndAction.Invoke();
 }