void OnDestroy() { if (_root != null) { _root.Clear(); } }
/// <summary> /// 重置根节点 /// </summary> protected void Reset() { if (root != null) { root.Clear(); } }
public override void Clear() { if (m_cChild != null) { m_cChild.Clear(); } }
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()); } }
/// <summary> /// 判断能否执行该节点 /// </summary> /// <returns></returns> protected override bool DoEvaluate() { // 孩子节点中至少有一个可以执行 foreach (BTNode child in children) { if (child.Evaluate()) { if (activeChild != null && activeChild != child) { activeChild.Clear(); } activeChild = child; return(true); } } // 否则不进行选择 if (activeChild != null) { activeChild.Clear(); activeChild = null; } return(false); }
protected override void Exit() { child.Clear(); }