Пример #1
0
    private IEnumerator move()
    {
        if (currentWaypoint >= path.vectorPath.Length)
        {
            yield return(null);
        }
        if (path.nextNode(currentWaypoint, nextWaypointDistance))
        {
            currentWaypoint++;
        }
        if (jump)
        {
            StartCoroutine(Jump());
            yield return(null);
        }
        else
        {
            if (path.nodePath[currentWaypoint].thisNodeType == Node.nodeType.jump && path.nodePath[currentWaypoint + 1].location.y > path.nodePath[currentWaypoint].location.y)
            {
                jump = true;
                anim.SetBool("Jump", true);
                anim.SetBool("Grounded", false);
                yield return(null);
            }
            else
            {
                startJump = true;
                Vector3 dir      = (path.vectorPath[currentWaypoint]);
                Vector3 velocity = dir * moveScale;
                //Debug.Log("Velocity - " + velocity);
                if (velocity.x < 0)
                {
                    transform.localScale = new Vector3(-1, 1, 1);
                }
                else if (velocity.x > 0)
                {
                    transform.localScale = new Vector3(1, 1, 1);
                }
                transform.position += velocity;
                anim.SetBool("IsWalking", true);
                anim.SetBool("Grounded", true);
            }
        }

        yield return(null);
    }