public override BTResult Tick() { // first time if (_activeChild == null) { _activeChild = children[0]; _activeIndex = 0; } BTResult result = _activeChild.Tick(); if (result == BTResult.Ended) { // Current active node over _activeIndex++; if (_activeIndex >= children.Count) { // sequence is over _activeChild.Clear(); _activeChild = null; _activeIndex = -1; } else { // next node _activeChild.Clear(); _activeChild = children[_activeIndex]; result = BTResult.Running; } } return(result); }
public override BTResult Tick() { if (_activeChild == null) { return(BTResult.Ended); } BTResult result = _activeChild.Tick(); if (result != BTResult.Running) { _activeChild.Clear(); _activeChild = null; } return(result); }
public void DoUpdate() { if (!isRunning) { return; } //if(++frameCount>=framePeriod) { // frameCount = 0; // if (database.GetData<bool>(RESET)) // { // Reset(); // database.SetData<bool>(RESET, false); // } // Iterate the BT tree now! if (_root.Evaluate()) { _root.Tick(); } } }