/// <summary> /// 返回状态给父节点 /// </summary> /// <param name="childNode"></param> /// <param name="status"></param> public void ReturnToParent(BevNode childNode, BevRunningStatus status) { OnExit(); if (parentNode != null) { parentNode.AcceptReturn(childNode, status); } }
protected void SetActiveNode(BevNode node) { LastActiveNode = ActiveNode; ActiveNode = node; if (parentNode != null) { parentNode.SetActiveNode(node); } }
protected IEnumerator DelayTickChild(BevNode childNode, float delayTime = -1) { if (delayTime == -1) { delayTime = ownTree.TickTime; } yield return(new WaitForSeconds(delayTime)); childNode.Tick(); }
/// <summary> /// 接受子节点返回 /// </summary> public override void DoReturn(BevNode childNode, BevRunningStatus status) { chindNodeStatusList[childNodeList.IndexOf(childNode)] = status; if (status == BevRunningStatus.Executing) { DelayTickChild(childNode); } else if (status == BevRunningStatus.Failure) { ReturnToParent(this, BevRunningStatus.Failure); } else if (status == BevRunningStatus.Succeed) { for (int i = 0; i < childNodeList.Count; i++) { if (chindNodeStatusList[i] == BevRunningStatus.Failure) { ReturnToParent(this, BevRunningStatus.Failure); } } ReturnToParent(this, BevRunningStatus.Succeed); } }
/// <summary> /// 接受子节点返回 /// </summary> public override void DoReturn(BevNode childNode, BevRunningStatus status) { if (status == BevRunningStatus.Failure) { ReturnToParent(this, BevRunningStatus.Failure); } else if (status == BevRunningStatus.Succeed) { int curIndex = childNodeList.IndexOf(childNode); if (curIndex == childNodeList.Count - 1) { ReturnToParent(this, BevRunningStatus.Succeed); } else { childNodeList[curIndex + 1].Tick(); } } else if (status == BevRunningStatus.Executing) { DelayTickChild(childNode); } }
/// <summary> /// 接受子节点返回 /// </summary> public void AcceptReturn(BevNode childNode, BevRunningStatus status) { ownTree.CurNode = this; DoReturn(childNode, status); }
public ActionNode(BevTree ownTree, BevNode parentNode = null) : base(ownTree, parentNode) { }
public ParallelAndNode(BevTree ownTree, BevNode parentNode = null) : base(ownTree, parentNode) { }
public void AddChildNode(BevNode node) { childNodeList.Add(node); }
public BevNode(BevTree ownTree, BevNode parentNode = null, Condition enterCondition = null) { this.parentNode = parentNode; this.enterCondition = enterCondition; this.ownTree = ownTree; }
public SelectorNode(BevTree ownTree, BevNode parentNode = null) : base(ownTree, parentNode) { }
public void RemoveChild(BevNode bevNode) { childNodeList.Remove(bevNode); }
public void AddChild(BevNode bevNode) { childNodeList.Add(bevNode); }
public CompositeNode(BevTree ownTree, BevNode parentNode = null) : base(ownTree, parentNode) { childNodeList = new List <BevNode>(); }
public SequenceNode(BevTree ownTree, BevNode parentNode = null) : base(ownTree, parentNode) { }
/* 可重写接口 */ /// <summary> /// 子节点返回内容之后调用,根据子节点状态返回状态到父节点 /// </summary> /// <param name="childNode"></param> /// <param name="status"></param> public virtual void DoReturn(BevNode childNode, BevRunningStatus status) { }
public MoveAction(BevTree ownTree, BevNode parentNode = null) : base(ownTree, parentNode) { ownObj = ownTree.gameObject; navAgent = ownObj.GetComponent <NavMeshAgent>(); }