Exemplo n.º 1
0
        protected override IEnumerator process(BehaviourTreeAgent agent)
        {
            BehaviourTreeNodeState myState = stateForAgent(agent);

            foreach (ConnectionPort knob in outputPorts)
            {
                if (knob.connected())
                {
                    BehaviourTreeNode      node       = knob.connection(0).body as BehaviourTreeNode;
                    BehaviourTreeNodeState childState = node.stateForAgent(agent);
                    yield return(agent.StartCoroutine(node.routine(childState)));

                    if (childState.actualCondition == processCondition.Sucess)
                    {
                        myState.actualCondition = processCondition.Sucess;
                    }
                    if (myState.actualCondition == processCondition.Sucess)
                    {
                        yield break;
                    }
                }
            }
            if (myState.actualCondition == processCondition.Running)
            {
                myState.actualCondition = processCondition.Failure;
            }
        }
Exemplo n.º 2
0
 void Start()
 {
     nodes  = new List <BehaviourTreeNodeState>();
     states = new Dictionary <Vector2, BehaviourTreeNodeState>();
     if (tree == null)
     {
         throw new MissingReferenceException(name + " has no Behaviour Tree");
     }
     tree.Validate();
     foreach (Node node in tree.nodes)
     {
         BehaviourTreeNodeState state = new BehaviourTreeNodeState
         {
             agent           = this,
             node            = node as BehaviourTreeNode,
             actualCondition = processCondition.Stopped
         };
         nodes.Add(state);
         states.Add(node.position, state);
         if (node.isInput())
         {
             root = node as BehaviourTreeNode;
         }
     }
     StartThinking();
 }
Exemplo n.º 3
0
        protected override IEnumerator process(BehaviourTreeAgent agent)
        {
            BehaviourTreeNodeState state      = stateForAgent(agent);
            BehaviourTreeNode      child      = outputKnob.connection(0).body as BehaviourTreeNode;
            BehaviourTreeNodeState childState = child.stateForAgent(agent);

            yield return(agent.StartCoroutine(child.routine(childState)));

            state.actualCondition = processCondition.Sucess;
        }
Exemplo n.º 4
0
        protected override IEnumerator process(BehaviourTreeAgent agent)
        {
            actualRepetition = 0;
            BehaviourTreeNodeState state      = stateForAgent(agent);
            BehaviourTreeNode      child      = outputKnob.connection(0).body as BehaviourTreeNode;
            BehaviourTreeNodeState childState = child.stateForAgent(agent);

            while (repeatForever || actualRepetition < repetitionQuantity)
            {
                yield return(agent.StartCoroutine(child.routine(childState)));

                actualRepetition++;
            }
            state.actualCondition = childState.actualCondition;
        }
Exemplo n.º 5
0
        protected override IEnumerator process(BehaviourTreeAgent agent)
        {
            actualRepetition = 0;
            BehaviourTreeNodeState state      = stateForAgent(agent);
            BehaviourTreeNode      child      = outputKnob.connection(0).body as BehaviourTreeNode;
            BehaviourTreeNodeState childState = child.stateForAgent(agent);

            do
            {
                yield return(agent.StartCoroutine(child.routine(childState)));

                actualRepetition++;
            } while ((repeatForever || actualRepetition < repetitionQuantity) && childState.actualCondition != processCondition.Failure);
            if (childState.actualCondition == processCondition.Failure)
            {
                state.actualCondition = processCondition.Sucess;
            }
            if (childState.actualCondition == processCondition.Sucess)
            {
                state.actualCondition = processCondition.Failure;
            }
        }