Ejemplo n.º 1
0
        public override BTResult OnTick(BTBlackBoard blackBoard)
        {
            int count = m_lstChild.Count;

            for (int i = 0; i < count; i++)
            {
                if (m_lstResults[i] == BTResult.Running)
                {
                    BTResult childResult = m_lstChild[i].OnTick(blackBoard);
                    if (childResult != BTResult.Running)
                    {
                        m_lstResults[i] = childResult;
                        m_iCount++;
                    }
                }
            }
            if (m_iCount == count)
            {
                for (int i = 0; i < count; i++)
                {
                    //只要有一个成功了,那么返回成功
                    if (m_lstResults[i] == BTResult.Success)
                    {
                        return(BTResult.Success);
                    }
                }
                return(BTResult.Failure);
            }
            return(BTResult.Running);
        }
Ejemplo n.º 2
0
        protected override BTResult OnCompositeTick(BTBlackBoard blackBoard)
        {
            int curIndex   = m_iSelectedIndex;
            int totalCount = m_lstChild.Count;

            if (curIndex < totalCount)
            {
                var      child       = m_lstChild[curIndex];
                BTResult childResult = this.OnRunningChildTick(child, blackBoard);
                if (childResult == BTResult.Failure)
                {
                    return(BTResult.Failure);
                }
                else if (childResult == BTResult.Success)
                {
                    m_iSelectedIndex++;
                }
            }
            if (m_iSelectedIndex < totalCount)
            {
                return(BTResult.Running);
            }
            else
            {
                return(BTResult.Success);
            }
        }
Ejemplo n.º 3
0
 public virtual BTResult OnEnter(BTBlackBoard blackBoard)
 {
     if (m_cChild == null)
     {
         return(BTResult.Success);
     }
     return(m_cChild.OnTick(blackBoard));
 }
Ejemplo n.º 4
0
 sealed public override BTResult OnTick(BTBlackBoard blackBoard)
 {
     if (m_cChild != null)
     {
         return(m_cChild.OnTick(blackBoard));
     }
     return(BTResult.Success);
 }
Ejemplo n.º 5
0
 public override bool Evaluate(BTBlackBoard blackBoard)
 {
     if (m_cChild == null)
     {
         return(true);
     }
     return(!m_cChild.Evaluate(blackBoard));
 }
Ejemplo n.º 6
0
 public override void Clear()
 {
     if (m_eActionResult == BTActionResult.Running)
     {
         OnExit(m_cBlackBoard);
         m_cBlackBoard = null;
     }
     m_eActionResult = BTActionResult.Ready;
 }
Ejemplo n.º 7
0
 sealed public override BTResult OnTick(BTBlackBoard blackBoard)
 {
     if (m_cRunningChild != null)
     {
         return(OnRunningChildTick(m_cRunningChild, blackBoard));
     }
     else
     {
         return(OnCompositeTick(blackBoard));
     }
 }
Ejemplo n.º 8
0
        public override bool Evaluate(BTBlackBoard blackBoard)
        {
            bool result = true;
            int  count  = m_lstChild.Count;

            for (int i = 0; i < count; i++)
            {
                result = result || (m_lstChild[i] as BTCondition).Evaluate(blackBoard);
            }
            return(result);
        }
Ejemplo n.º 9
0
 sealed public override BTResult OnTick(BTBlackBoard blackBoard)
 {
     if (Evaluate(blackBoard))
     {
         return(BTResult.Success);
     }
     else
     {
         return(BTResult.Failure);
     }
 }
Ejemplo n.º 10
0
        public override bool Evaluate(BTBlackBoard blackBoard)
        {
            bool result = true;
            int  count  = m_lstCondition.Count;

            for (int i = 0; i < count; i++)
            {
                result = result && m_lstCondition[i].Evaluate(blackBoard);
            }
            return(result);
        }
Ejemplo n.º 11
0
        //如果子对象在running状态中,那么,下一帧直接执行
        protected BTResult OnRunningChildTick(BTNode child, BTBlackBoard blackBoard)
        {
            BTResult result = child.OnTick(blackBoard);

            if (result == BTResult.Running)
            {
                m_cRunningChild = child;
            }
            else
            {
                m_cRunningChild = null;
            }
            return(result);
        }
Ejemplo n.º 12
0
        public override BTResult OnTick(BTBlackBoard blackBoard)
        {
            int count = m_lstChild.Count;

            for (int i = 0; i < count; i++)
            {
                BTResult childResult = m_lstChild[i].OnTick(blackBoard);
                if (childResult != BTResult.Running)
                {
                    return(childResult);
                }
            }
            return(BTResult.Running);
        }
Ejemplo n.º 13
0
 sealed public override BTResult OnTick(BTBlackBoard blackBoard)
 {
     if (m_eActionResult == BTActionResult.Ready)
     {
         OnEnter(blackBoard);
         m_eActionResult = BTActionResult.Running;
     }
     m_eActionResult = OnRun(blackBoard);
     if (m_eActionResult == BTActionResult.Ready)
     {
         OnExit(blackBoard);
     }
     if (m_eActionResult == BTActionResult.Running)
     {
         return(BTResult.Running);
     }
     return(BTResult.Success);
 }
Ejemplo n.º 14
0
        public override BTResult OnTick(BTBlackBoard blackBoard)
        {
            FP deltaTime = blackBoard.deltaTime;

            if (m_bIsEnd)
            {
                m_bIsEnd = false;
                m_sTime  = 0;
                m_nCount = 0;
            }
            int count = m_lstChild.Count;

            for (int i = 0; i < count; i++)
            {
                if (m_lstResults[i] == BTResult.Running)
                {
                    BTNode          child        = m_lstChild[i];
                    IBTTimeLineNode timeLineNode = child as IBTTimeLineNode;
                    if (timeLineNode.time <= m_sTime)
                    {
                        BTResult result = child.OnTick(blackBoard);
                        if (result != BTResult.Running)
                        {
                            m_lstResults[i] = result;
                            m_nCount++;
                        }
                    }
                }
            }
            m_sTime += deltaTime;
            if (m_nCount == count)
            {
                m_bIsEnd = true;
                return(BTResult.Success);
            }
            return(BTResult.Running);
        }
Ejemplo n.º 15
0
        protected override BTResult OnCompositeTick(BTBlackBoard blackBoard)
        {
            int curIndex      = m_iSelectedIndex;
            int selectedCount = 0;
            int totalCount    = m_lstChild.Count;

            while (selectedCount < totalCount)
            {
                curIndex = curIndex % totalCount;
                var      child       = m_lstChild[curIndex];
                BTResult childResult = this.OnRunningChildTick(child, blackBoard);
                if (childResult == BTResult.Failure)
                {
                    curIndex++;
                    selectedCount++;
                }
                else
                {
                    m_iSelectedIndex = curIndex;
                    return(childResult);
                }
            }
            return(BTResult.Failure);
        }
Ejemplo n.º 16
0
 public virtual void OnEnter(BTBlackBoard blackBoard)
 {
 }
Ejemplo n.º 17
0
 public virtual BTResult Decorate(BTBlackBoard bloackBoard, BTResult result)
 {
     return(result);
 }
Ejemplo n.º 18
0
 //可重写
 protected virtual BTResult OnCompositeTick(BTBlackBoard blackBoard)
 {
     return(base.OnTick(blackBoard));
 }
Ejemplo n.º 19
0
        sealed public override BTResult OnTick(BTBlackBoard blackBoard)
        {
            BTResult result = OnEnter(blackBoard);

            return(Decorate(blackBoard, result));
        }
Ejemplo n.º 20
0
 public virtual void OnExit(BTBlackBoard blackBoard)
 {
 }
Ejemplo n.º 21
0
 public virtual bool Evaluate(BTBlackBoard blackBoard)
 {
     return(true);
 }
Ejemplo n.º 22
0
 public override bool Evaluate(BTBlackBoard blackBoard)
 {
     return(!m_cChild.Evaluate(blackBoard));
 }
Ejemplo n.º 23
0
 public virtual BTActionResult OnRun(BTBlackBoard blackBoard)
 {
     return(BTActionResult.Running);
 }
Ejemplo n.º 24
0
 public virtual BTResult OnTick(BTBlackBoard blackBoard)
 {
     return(BTResult.Success);
 }
Ejemplo n.º 25
0
 public virtual BTResult OnEnter(BTBlackBoard blackBoard)
 {
     return(m_cChild.OnTick(blackBoard));
 }