protected override bool onEvaluate(/*in*/ TBTWorkingData wData) { TBTActionPrioritizedSelectorContext thisContext = getContext <TBTActionPrioritizedSelectorContext>(wData); thisContext.currentSelectedIndex = -1; int childCount = GetChildCount(); for (int i = 0; i < childCount; ++i) { TBTAction node = GetChild <TBTAction>(i); if (node.Evaluate(wData)) { thisContext.currentSelectedIndex = i; return(true); } } return(false); }
protected override bool onEvaluate(/*in*/ TBTWorkingData wData) { TBTActionPrioritizedSelectorContext thisContext = getContext <TBTActionPrioritizedSelectorContext>(wData); thisContext.currentSelectedIndex = -1; int childCount = GetChildCount(); // 按顺序依次判断所有的子节点,只要有一个子节点满足条件就说明处于这个行为树节点,那么这个父节点也就处于这个状态 // 并设置当前子节点为父节点的当前index for (int i = 0; i < childCount; ++i) { TBTAction node = GetChild <TBTAction>(i); if (node.Evaluate(wData)) { // 只要一个符合,那么就执行这个 thisContext.currentSelectedIndex = i; return(true); } } return(false); }
//------------------------------------------------------- protected override bool onEvaluate(/*in*/ TBTWorkingData wData) { TBTActionTimerContext thisContext = getContext <TBTActionTimerContext>(wData); if (thisContext.lastTime == INFINITY) { thisContext.lastTime = UnityEngine.Time.time; } bool checkTimerOver = (UnityEngine.Time.time >= thisContext.lastTime + m_elapseTime); if (checkTimerOver == false) { return(false); } if (IsIndexValid(0)) { TBTAction node = GetChild <TBTAction>(0); return(node.Evaluate(wData)); } return(false); }
//------------------------------------------------------ protected override bool onEvaluate(/*in*/ TBTWorkingData wData) { TBTActionSequenceContext thisContext = getContext <TBTActionSequenceContext>(wData); int checkedNodeIndex = -1; if (IsIndexValid(thisContext.currentSelectedIndex)) { checkedNodeIndex = thisContext.currentSelectedIndex; } else { checkedNodeIndex = 0; } if (IsIndexValid(checkedNodeIndex)) { TBTAction node = GetChild <TBTAction>(checkedNodeIndex); if (node.Evaluate(wData)) { thisContext.currentSelectedIndex = checkedNodeIndex; return(true); } } return(false); }