Ejemplo n.º 1
0
    public void Start(AIAgent newAgent)
    {
        agent = newAgent;

        agent.EndChase();
        currentPatrolNode    = startingPatrolNode;
        agent.lastPatrolNode = currentPatrolNode;
        agent.navAgent.Stop();


        if (enablePatrolling)
        {
            patrolNodes = new List <PatrolNode>();
            patrolNodes.Add(startingPatrolNode);

            pingPongState = true;

            while (patrolNodes[patrolNodes.Count - 1].nextNode != null && !patrolNodes.Contains(patrolNodes[patrolNodes.Count - 1].nextNode))
            {
                patrolNodes.Add(patrolNodes[patrolNodes.Count - 1].nextNode);
            }

            if (fixedPosition == true)
            {
                SetSubstate(Substate.returningToPost);
                return;
            }

            SetNextNode(currentPatrolNode);
        }
    }