Пример #1
0
 /// <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);
     }
 }
Пример #2
0
 protected void SetActiveNode(BevNode node)
 {
     LastActiveNode = ActiveNode;
     ActiveNode     = node;
     if (parentNode != null)
     {
         parentNode.SetActiveNode(node);
     }
 }
Пример #3
0
    protected IEnumerator DelayTickChild(BevNode childNode, float delayTime = -1)
    {
        if (delayTime == -1)
        {
            delayTime = ownTree.TickTime;
        }
        yield return(new WaitForSeconds(delayTime));

        childNode.Tick();
    }
Пример #4
0
 /// <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);
     }
 }
Пример #5
0
 /// <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);
     }
 }
Пример #6
0
 /// <summary>
 /// 接受子节点返回
 /// </summary>
 public void AcceptReturn(BevNode childNode, BevRunningStatus status)
 {
     ownTree.CurNode = this;
     DoReturn(childNode, status);
 }
Пример #7
0
 public ActionNode(BevTree ownTree, BevNode parentNode = null) : base(ownTree, parentNode)
 {
 }
Пример #8
0
 public ParallelAndNode(BevTree ownTree, BevNode parentNode = null) : base(ownTree, parentNode)
 {
 }
Пример #9
0
 public void AddChildNode(BevNode node)
 {
     childNodeList.Add(node);
 }
Пример #10
0
 public BevNode(BevTree ownTree, BevNode parentNode = null, Condition enterCondition = null)
 {
     this.parentNode     = parentNode;
     this.enterCondition = enterCondition;
     this.ownTree        = ownTree;
 }
Пример #11
0
 public SelectorNode(BevTree ownTree, BevNode parentNode = null) : base(ownTree, parentNode)
 {
 }
Пример #12
0
 public void RemoveChild(BevNode bevNode)
 {
     childNodeList.Remove(bevNode);
 }
Пример #13
0
 public void AddChild(BevNode bevNode)
 {
     childNodeList.Add(bevNode);
 }
Пример #14
0
 public CompositeNode(BevTree ownTree, BevNode parentNode = null) : base(ownTree, parentNode)
 {
     childNodeList = new List <BevNode>();
 }
Пример #15
0
 public SequenceNode(BevTree ownTree, BevNode parentNode = null) : base(ownTree, parentNode)
 {
 }
Пример #16
0
    /* 可重写接口 */

    /// <summary>
    /// 子节点返回内容之后调用,根据子节点状态返回状态到父节点
    /// </summary>
    /// <param name="childNode"></param>
    /// <param name="status"></param>
    public virtual void DoReturn(BevNode childNode, BevRunningStatus status)
    {
    }
Пример #17
0
 public MoveAction(BevTree ownTree, BevNode parentNode = null) : base(ownTree, parentNode)
 {
     ownObj   = ownTree.gameObject;
     navAgent = ownObj.GetComponent <NavMeshAgent>();
 }