Пример #1
0
    protected override IEnumerator moveToTarget(Vector3 target, BattleState.State nextState, IAbility ability, float optionalDelay = 0, float stopDist = 1.5F)
    {
        coroutines.moveToTarget = true;
        agent.ResetPath();

        if (optionalDelay > 0)
            yield return new WaitForSeconds(optionalDelay);

        while (anim.GetCurrentAnimatorStateInfo(0).fullPathHash != animHash.getHash("idleState"))
            yield return null;

        while (!ability.moveToTarget(this.gameObject, target, stopDist))
        {
            float moveSpeed = agent.velocity.magnitude;

            anim.SetFloat(animHash.getHash("moveSpeedFloat"), moveSpeed);

            yield return null;
        }

        agent.Stop();
        agent.ResetPath();
        anim.SetFloat(animHash.getHash("moveSpeedFloat"), 0.1f);
        state.setState(nextState);
        coroutines.moveToTarget = false;
    }