Beispiel #1
0
 public virtual BTNodeState Run(T obj)
 {
     Enter(obj);
     mNodeState = Process(obj);
     Leave(obj);
     return(mNodeState);
 }
        protected override BTNodeState Handle()
        {
            BTNodeState result = BTNodeState.Running;
            int         count  = 0;

            foreach (BehaviourTreeNode node in mChildren)
            {
                if (((IBTParallelFunc)node).NodeStatus() == BTNodeState.Success)
                {
                    result = BTNodeState.Success;
                    break;
                }
                else if (((IBTParallelFunc)node).NodeStatus() == BTNodeState.Running)
                {
                    continue;
                }
                else if (((IBTParallelFunc)node).NodeStatus() == BTNodeState.Failure)
                {
                    count++;
                }
            }
            if (count == mChildren.Count)
            {
                result = BTNodeState.Failure;
            }
            return(result);
        }
Beispiel #3
0
    public override BTNodeState Evaluate(BehaviourController controller)
    {
        bool nodeRunning = false;

        foreach (BTNode node in nodes)
        {
            BTNodeState currentNodeState = node.Evaluate(controller);
            switch (currentNodeState)
            {
            case BTNodeState.SUCCESS:
                continue;

            case BTNodeState.RUNNING:
                nodeRunning = true;
                continue;

            case BTNodeState.FAILURE:
                return(currentNodeState);

            default:
                break;
            }
        }

        return(nodeRunning? BTNodeState.RUNNING : BTNodeState.SUCCESS);
    }
Beispiel #4
0
 public BTNode(int nodeId, BehaviourTree tree, BTNode parent)
 {
     _nodeId = nodeId;
     _tree   = tree;
     _parent = parent;
     _state  = BTNodeState.SUCCESS;
 }
    public override BTNodeState start()
    {
        BTNodeState result = mNodeFunction();

        if (result == BTNodeState.Running)
        {
            return(BTNodeState.Error);
        }

        return(result);
    }
Beispiel #6
0
    public override BTNodeState Evaluate(BehaviourController controller)
    {
        foreach (BTNode node in nodes)
        {
            BTNodeState currentNodeState = node.Evaluate(controller);
            switch (currentNodeState)
            {
            case BTNodeState.SUCCESS:
                return(currentNodeState);

            case BTNodeState.FAILURE:
                continue;

            default:
                break;
            }
        }

        return(BTNodeState.FAILURE);
    }
Beispiel #7
0
        public override BTNodeState Process(Target obj)
        {
            BTNodeState state = LeftOperation.Process(obj);

            if (RangeBoolean == BTConditionBoolean.AND)
            {
                if (state == BTNodeState.Success)
                {
                    state = RightOperation.Process(obj);
                }
            }
            else if (RangeBoolean == BTConditionBoolean.OR)
            {
                if (state == BTNodeState.Failure)
                {
                    state = RightOperation.Process(obj);
                }
            }

            return(state);
        }
 protected virtual void Fail() {
   _state = BTNodeState.FAILURE;
   Finish();
 }
 protected virtual void Succeed() {
   _state = BTNodeState.SUCCESS;
   Finish();
 }
 public BTNode(int nodeId, BehaviourTree tree, BTNode parent) {
   _nodeId = nodeId;
   _tree = tree;
   _parent = parent;
   _state = BTNodeState.SUCCESS;
 }
Beispiel #11
0
 public BehaviourTreeNode()
 {
     mRunningNode = null;
     mNodeState   = BTNodeState.Ready;
 }
Beispiel #12
0
 protected virtual void Fail()
 {
     _state = BTNodeState.FAILURE;
     Finish();
 }
Beispiel #13
0
 protected virtual void Succeed()
 {
     _state = BTNodeState.SUCCESS;
     Finish();
 }
Beispiel #14
0
 public BehaviourTreeNode()
 {
     mNodeState = BTNodeState.Ready;
 }