Beispiel #1
0
    protected IEnumerator Perform_Coroutine()
    {
        yield return(StartCoroutine(PreCast()));

        if (!string.IsNullOrEmpty(castTrigger))
        {
            animator.SetFloat("CastSpeed", 1f / castTime);
            animator.SetTrigger(castTrigger);
            yield return(new WaitForCast(animator));
        }

        if (cancelled)
        {
            if (OnCancelled != null)
            {
                OnCancelled.Invoke(this);
            }
            yield break;
        }

        if (OnPerformed != null)
        {
            OnPerformed.Invoke(this);
        }

        yield return(StartCoroutine(PerformAction()));

        actionInProgress = null;
    }
    private IEnumerator Perform_Coroutine()
    {
        Quaternion q = Quaternion.LookRotation(direction, target.up);

        while (Quaternion.Angle(target.rotation, q) > turnSpeed * Time.deltaTime)
        {
            Quaternion r = Quaternion.RotateTowards(target.rotation, q, turnSpeed * Time.deltaTime);
            target.rotation = r;
            yield return(new WaitForEndOfFrame());
        }

        target.rotation = q;
        if (OnPerformed != null)
        {
            OnPerformed.Invoke(this);
        }

        actionInProgress = null;
    }
Beispiel #3
0
 protected void CallPerform(object args, params Object[] parameters) => OnPerformed?.Invoke(args, parameters);