protected override int onUpdate(TBTWorkingData wData) { TBTActionPrioritizedSelectorContext thisContext = getContext <TBTActionPrioritizedSelectorContext>(wData); int runningState = TBTRunningStatus.FINISHED; if (thisContext.currentSelectedIndex != thisContext.lastSelectedIndex) { if (IsIndexValid(thisContext.lastSelectedIndex)) { TBTAction node = GetChild <TBTAction>(thisContext.lastSelectedIndex); node.Transition(wData); } thisContext.lastSelectedIndex = thisContext.currentSelectedIndex; } if (IsIndexValid(thisContext.lastSelectedIndex)) { TBTAction node = GetChild <TBTAction>(thisContext.lastSelectedIndex); runningState = node.Update(wData); if (TBTRunningStatus.IsFinished(runningState)) { node.Transition(wData); thisContext.lastSelectedIndex = -1; } } return(runningState); }
public int UpdateReqeust(float gameTime, float deltaTime) { if (_nextRequest != _currentRequest) { //reset bev tree _behaviorTree.Transition(_behaviorWorkingData); //assign to current _currentRequest = _nextRequest; //reposition and add a little offset Vector3 targetPos = _currentRequest.nextMovingTarget + TMathUtils.GetDirection2D(_currentRequest.nextMovingTarget, transform.position) * 0.2f; Vector3 startPos = new Vector3(targetPos.x, -1.4f, targetPos.z); _targetDummyObject.transform.position = startPos; LeanTween.move(_targetDummyObject, targetPos, 1f); } return(0); }
protected override void onTransition(TBTWorkingData wData) { GuideRoot_01Context thisContext = getContext <GuideRoot_01Context>(wData); TBTAction node = GetChild <TBTAction>(thisContext.currentSelectedIndex); if (node != null) { node.Transition(wData); } }
protected override void onTransition(TBTWorkingData wData) { TBTActionPrioritizedSelectorContext thisContext = getContext <TBTActionPrioritizedSelectorContext>(wData); TBTAction node = GetChild <TBTAction>(thisContext.lastSelectedIndex); if (node != null) { node.Transition(wData); } thisContext.lastSelectedIndex = -1; }
private void Update() { if (_behaviorTree.Evaluate(_behaviorWorkingData)) { _behaviorTree.Update(_behaviorWorkingData); } else { _behaviorTree.Transition(_behaviorWorkingData); } }
//public override void AddBody(bool isStrong = false) //{ //} public int UpdateBehavior(float gameTime, float deltaTime) { _BevWorkingData._GameTime = gameTime; _BevWorkingData._DeltaTime = deltaTime; if (_BevTree.Evaluate(_BevWorkingData)) { _BevTree.Update(_BevWorkingData); } else { _BevTree.Transition(_BevWorkingData); } return(0); }
// 更新请求 public int UpdateRequest(float gameTime, float deltaTime) { AIBehaviorRequest foregroundRequest = m_BehaviorWorkData.request; AIBehaviorRequest backgroundRequest = m_DecisionWorkData.request; if (backgroundRequest != foregroundRequest) { //比对决策树和行为树的请求是否一致 if (foregroundRequest != null) { GameLog.Log("【UpdateRequest】当前在处理的请求(前端):" + foregroundRequest.ToString()); } if (backgroundRequest != null) { GameLog.Log("【UpdateRequest】下一个要处理的请求(后端):" + backgroundRequest.ToString()); } //reset bev tree 清理一些状态 m_BehaviorTree.Transition(m_BehaviorWorkData); //assign to current m_BehaviorWorkData.request = backgroundRequest; } return(0); }