コード例 #1
0
ファイル: FSMState.cs プロジェクト: CCChaos/big-tooth
        /// <summary>
        /// 获取状态机该状态下的下一个转换状态
        /// </summary>
        /// <param name="fsmEntity"></param>
        /// <returns></returns>
        public virtual UInt32 GetFSMTransState(CFSM fsmEntity)
        {
            UInt32 uNextState = cuInvalieStateId;

            if (m_TransitionList == null)
            {
                return(uNextState);
            }
            Int32 nSize = m_TransitionList.Count;

            for (Int32 i = 0; i < nSize; ++i)
            {
                CFSMTransition fsmTrans = m_TransitionList[i];
                if (fsmTrans == null)
                {
                    continue;
                }
                if (fsmTrans.CheckTransition(fsmEntity) == true)
                {
                    uNextState = fsmTrans.GetTargetStateId();
                    break;
                }
            }
            return(uNextState);
        }
コード例 #2
0
        // 创建转换列表
        private List <CFSMTransition> CreateTransitionListFromXML(List <CFSMXMLTranslation> transitionXMLList)
        {
            if (transitionXMLList == null)
            {
                return(null);
            }
            List <CFSMTransition> tranList = new List <CFSMTransition>();
            Int32 nTransSize = transitionXMLList == null ? 0 : transitionXMLList.Count;

            for (Int32 i = 0; i < nTransSize; ++i)
            {
                CFSMXMLTranslation xmlTrans = transitionXMLList[i];
                if (xmlTrans == null)
                {
                    continue;
                }
                CFSMTransition newTrans = new CFSMTransition(xmlTrans.m_uTargetId);
                if (newTrans.CreateFromXML(xmlTrans) == false)
                {
                    BTMISC.BTDebug.Warning("<BTFSM> Create FSM Transition Failed");
                    continue;
                }
                tranList.Add(newTrans);
            }
            return(tranList);
        }
コード例 #3
0
ファイル: FSMState.cs プロジェクト: CCChaos/big-tooth
 /// <summary>
 /// 添加一条转换
 /// </summary>
 /// <param name="fsmTrans"></param>
 /// <returns></returns>
 public bool AddTransition(CFSMTransition fsmTrans)
 {
     if (fsmTrans == null || m_TransitionList == null)
     {
         return(false);
     }
     m_TransitionList.Add(fsmTrans);
     return(true);
 }