Exemplo n.º 1
0
 /// <summary>
 /// 评估当前节点,如果没有就取第一个
 /// </summary>
 public override bool DoEvaluate()
 {
     if (m_curActiveChild != null)
     {
         // 评估不通过,清除当前节点
         bool result = m_curActiveChild.Evaluate();
         if (!result)
         {
             m_curActiveChild.Clear();
             m_curActiveChild = null;
             m_curActiveIndex = -1;
         }
         return(result);
     }
     else
     {
         return(m_children[0].Evaluate());
     }
 }
Exemplo n.º 2
0
 /// <summary>
 /// 一般情况作为树的父节点,开始检查条件,满足后执行DoEvaluate,遍历子节点
 /// 遍历评估能通过的节点,设置为当前节点,然后tick
 /// </summary>
 public override bool DoEvaluate()
 {
     if (m_children != null)
     {
         foreach (BtNode child in m_children)
         {
             if (child.Evaluate())
             {
                 if (m_curActiveChild != null && m_curActiveChild != child)
                 {
                     m_curActiveChild.Clear();
                 }
                 m_curActiveChild = child;
                 return(true);
             }
         }
     }
     m_curActiveChild = null;
     return(false);
 }
Exemplo n.º 3
0
 public void Reset()
 {
     m_root.Clear();
 }