コード例 #1
0
ファイル: BTParallelAnd.cs プロジェクト: 353162889/NodeEditor
        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);
        }
コード例 #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);
            }
        }
コード例 #3
0
 public virtual BTResult OnEnter(BTBlackBoard blackBoard)
 {
     if (m_cChild == null)
     {
         return(BTResult.Success);
     }
     return(m_cChild.OnTick(blackBoard));
 }
コード例 #4
0
ファイル: BTRoot.cs プロジェクト: Hengle/NodeEditor
 sealed public override BTResult OnTick(BTBlackBoard blackBoard)
 {
     if (m_cChild != null)
     {
         return(m_cChild.OnTick(blackBoard));
     }
     return(BTResult.Success);
 }
コード例 #5
0
 public override bool Evaluate(BTBlackBoard blackBoard)
 {
     if (m_cChild == null)
     {
         return(true);
     }
     return(!m_cChild.Evaluate(blackBoard));
 }
コード例 #6
0
ファイル: BTAction.cs プロジェクト: DongerGroup/FrameSync-1
 public override void Clear()
 {
     if (m_eActionResult == BTActionResult.Running)
     {
         OnExit(m_cBlackBoard);
         m_cBlackBoard = null;
     }
     m_eActionResult = BTActionResult.Ready;
 }
コード例 #7
0
 sealed public override BTResult OnTick(BTBlackBoard blackBoard)
 {
     if (m_cRunningChild != null)
     {
         return(OnRunningChildTick(m_cRunningChild, blackBoard));
     }
     else
     {
         return(OnCompositeTick(blackBoard));
     }
 }
コード例 #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);
        }
コード例 #9
0
 sealed public override BTResult OnTick(BTBlackBoard blackBoard)
 {
     if (Evaluate(blackBoard))
     {
         return(BTResult.Success);
     }
     else
     {
         return(BTResult.Failure);
     }
 }
コード例 #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);
        }
コード例 #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);
        }
コード例 #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);
        }
コード例 #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);
 }
コード例 #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);
        }
コード例 #15
0
ファイル: BTSelector.cs プロジェクト: Hengle/NodeEditor
        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);
        }
コード例 #16
0
ファイル: BTAction.cs プロジェクト: DongerGroup/FrameSync-1
 public virtual void OnEnter(BTBlackBoard blackBoard)
 {
 }
コード例 #17
0
 public virtual BTResult Decorate(BTBlackBoard bloackBoard, BTResult result)
 {
     return(result);
 }
コード例 #18
0
 //可重写
 protected virtual BTResult OnCompositeTick(BTBlackBoard blackBoard)
 {
     return(base.OnTick(blackBoard));
 }
コード例 #19
0
        sealed public override BTResult OnTick(BTBlackBoard blackBoard)
        {
            BTResult result = OnEnter(blackBoard);

            return(Decorate(blackBoard, result));
        }
コード例 #20
0
ファイル: BTAction.cs プロジェクト: DongerGroup/FrameSync-1
 public virtual void OnExit(BTBlackBoard blackBoard)
 {
 }
コード例 #21
0
 public virtual bool Evaluate(BTBlackBoard blackBoard)
 {
     return(true);
 }
コード例 #22
0
 public override bool Evaluate(BTBlackBoard blackBoard)
 {
     return(!m_cChild.Evaluate(blackBoard));
 }
コード例 #23
0
ファイル: BTAction.cs プロジェクト: DongerGroup/FrameSync-1
 public virtual BTActionResult OnRun(BTBlackBoard blackBoard)
 {
     return(BTActionResult.Running);
 }
コード例 #24
0
 public virtual BTResult OnTick(BTBlackBoard blackBoard)
 {
     return(BTResult.Success);
 }
コード例 #25
0
 public virtual BTResult OnEnter(BTBlackBoard blackBoard)
 {
     return(m_cChild.OnTick(blackBoard));
 }