Ejemplo n.º 1
0
        IEnumerator pathPlayer(PlayerCore player)
        {
            player.SetIsInteracting(false);
            PathData.Node current = GetNode(0);

            while (current != null)
            {
                Vector2 delta = current.position - (Vector2)player.transform.position - player.GetComponent <Rigidbody2D>().velocity *Time.fixedDeltaTime;
                player.MoveCraft(delta.normalized);
                if (delta.sqrMagnitude < PathAI.minDist)
                {
                    if (current.children.Count > 0)
                    {
                        int next = Random.Range(0, current.children.Count);
                        current = GetNode(current.children[next]);
                    }
                    else
                    {
                        current = null;
                    }
                }

                yield return(null);
            }

            player.SetIsInteracting(true);

            if (!asynchronous)
            {
                continueTraversing();
            }
        }