コード例 #1
0
        //If any child fails retunrs failure
        public override BTNodeStates Execute()
        {
            if (_currentNode == null && _nodeQueue.Count > 0)
            {
                _currentNode = _nodeQueue.Dequeue();
            }

            BTNodeStates nodeStatus = _currentNode.Execute();

            switch (nodeStatus)
            {
            case BTNodeStates.FAILURE:
                return(_nodeState = BTNodeStates.FAILURE);

            case BTNodeStates.SUCCESS:
                if (_nodeQueue.Count > 0)
                {
                    _currentNode = _nodeQueue.Dequeue();
                }
                else
                {
                    return(_nodeState = BTNodeStates.SUCCESS);
                }
                break;

            case BTNodeStates.RUNNING:
                _nodeState = BTNodeStates.RUNNING;
                break;

            default:
                return(_nodeState = BTNodeStates.SUCCESS);
            }

            return(BTNodeStates.RUNNING);
        }
コード例 #2
0
 public BTNodeStates Behave()
 {
     return(_currentStatus = _rootNode.Execute());
 }