void Update() { if (_rootNode.Evaluate()) { _rootNode.Tick(); } }
private void Update() { rootNode.Evaluate(); if (rootNode.NodeState == NodeState.Failure) { agent.isStopped = true; controller.Idle(); } }
public override bool OnEvaluate() { if (_activeBtNode == null) { _activeBtNode = ChildNode[0]; index = 0; } return(_activeBtNode.Evaluate()); }
public void PerformTurn_AI(int actionsPerTurn) { hasToMoveTroops = true; hasToMoveExplorers = true; hasToMoveLabourers = true; for (int i = 0; i < actionsPerTurn; i++) { behaviourTree.Evaluate(this); } }
protected override bool OnEvaluate(BTInput _input) { if (CheckIndex(mCurrentSelectIndex)) { BTNode node = mChildren[mCurrentSelectIndex]; if (node.Evaluate(_input)) { return(true); } } return(base.OnEvaluate(_input)); }
protected override bool OnEvaluate(BTInput _input) { for (int i = 0; i < childCount; i++) { BTNode node = mChildren[i]; if (node.Evaluate(_input)) { mCurrentSelectIndex = i; return(true); } } return(false); }
protected override bool OnEvaluate(BTInput _input) { bool checkLoopCount = loopCount == INFINITELOOP || mCurrentCount < loopCount; if (!checkLoopCount) { return(false); } if (CheckIndex(0)) { BTNode node = mChildren[0]; if (node.Evaluate(_input)) { return(true); } } return(false); }
void Update() { if (!isRunning) { return; } if (database.GetData <bool>(RESET)) { Reset(); database.SetData <bool>(RESET, false); } // 对整个树从根节点开始检查和运行 if (root.Evaluate()) { root.Tick(); } }
public override NodeStates Evaluate() { switch (childNode.Evaluate()) { case NodeStates.Fail: nodeState = NodeStates.Success; return(nodeState); case NodeStates.Success: nodeState = NodeStates.Fail; return(nodeState); case NodeStates.Running: nodeState = NodeStates.Running; return(nodeState); } nodeState = NodeStates.Success; return(nodeState); }
void Update() { if (!isRunning) { return; } if (database.GetData <bool>(RESET)) { Reset(); database.SetData <bool>(RESET, false); } // Iterate the BT tree now! if (_root.Evaluate()) { _root.Tick(); } }
// Reports a success if the child fails and a failure if the child succeeds. // Running will report as running. public override NodeStates Evaluate() { switch (m_node.Evaluate()) { case NodeStates.FAILURE: m_nodeState = NodeStates.SUCCESS; return(m_nodeState); case NodeStates.SUCCESS: m_nodeState = NodeStates.FAILURE; return(m_nodeState); case NodeStates.RUNNING: m_nodeState = NodeStates.RUNNING; return(m_nodeState); } m_nodeState = NodeStates.SUCCESS; return(m_nodeState); }
protected override bool DoEvaluate() { if (activeChild != null) { bool result = activeChild.Evaluate(); // 节点之间与关系 一个不能执行则后面不执行 if (!result) { activeChild.Clear(); activeChild = null; activeIndex = -1; } return(result); } else { //Debug.Log(children[0]); return(children[0].Evaluate()); } }
protected override bool OnEvaluate(BTInput _input) { int i; if (mCurrentIndex == INVALID_CHILD_NODE_INDEX) { i = 0; } else { i = mCurrentIndex; } if (CheckIndex(i)) { BTNode node = mChildren[i]; if (node.Evaluate(_input)) { return(true); } } return(false); }