Пример #1
0
        /// <summary>
        /// 获取有限状态机。
        /// </summary>
        /// <typeparam name="T">有限状态机持有者类型。</typeparam>
        /// <param name="name">有限状态机名称。</param>
        /// <returns>要获取的有限状态机。</returns>
        public IFSM <T> GetFsm <T>(string name) where T : class
        {
            FSMBase fsm = null;

            if (m_Fsms.TryGetValue(name, out fsm))
            {
                return((IFSM <T>)fsm);
            }

            return(null);
        }
Пример #2
0
        /// <summary>
        /// 获取所有有限状态机。
        /// </summary>
        /// <returns>所有有限状态机。</returns>
        public FSMBase[] GetAllFsms()
        {
            int index = 0;

            FSMBase[] fsms = new FSMBase[m_Fsms.Count];
            foreach (KeyValuePair <string, FSMBase> fsm in m_Fsms)
            {
                fsms[index++] = fsm.Value;
            }

            return(fsms);
        }
Пример #3
0
        /// <summary>
        /// 销毁有限状态机。
        /// </summary>
        /// <typeparam name="T">有限状态机持有者类型。</typeparam>
        /// <param name="name">要销毁的有限状态机名称。</param>
        /// <returns>是否销毁有限状态机成功。</returns>
        public bool DestroyFsm <T>(string name) where T : class
        {
            //TODO:非完全名称可能会出现重名
            //string fullName = Utility.Text.GetFullName<T>(name);
            string  fullName = name;
            FSMBase fsm      = null;

            if (m_Fsms.TryGetValue(fullName, out fsm))
            {
                fsm.Shutdown();
                return(m_Fsms.Remove(fullName));
            }

            return(false);
        }