예제 #1
0
        /// <summary>
        /// 有限状态机管理器轮询。
        /// </summary>
        /// <param name="elapseSeconds">逻辑流逝时间,以秒为单位。</param>
        /// <param name="realElapseSeconds">真实流逝时间,以秒为单位。</param>
        public void Update(float elapseSeconds, float realElapseSeconds)
        {
            m_TempFsms.Clear();
            if (m_Fsms.Count <= 0)
            {
                return;
            }

            for (int i = 0; i < m_FsmList.Count; i++)
            {
                m_TempFsms.Add(m_FsmList[i]);
            }

            for (int i = 0; i < m_TempFsms.Count; i++)
            {
                FsmBase fsm = m_TempFsms[i];

                if (fsm.IsDestroyed)
                {
                    continue;
                }

                fsm.Update(elapseSeconds, realElapseSeconds);
            }
        }
예제 #2
0
        /// <summary>
        /// 销毁有限状态机。
        /// </summary>
        /// <param name="fsm">要销毁的有限状态机。</param>
        /// <returns>是否销毁有限状态机成功。</returns>
        public bool DestroyFsm(FsmBase fsm)
        {
            if (fsm == null)
            {
                throw new GameFrameworkException("FSM is invalid.");
            }

            return(InternalDestroyFsm(Utility.Text.GetFullName(fsm.OwnerType, fsm.Name)));
        }
예제 #3
0
        private FsmBase InternalGetFsm(string fullName)
        {
            FsmBase fsm = null;

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

            return(null);
        }
예제 #4
0
        /// <summary>
        /// 获取所有有限状态机。
        /// </summary>
        /// <returns>所有有限状态机。</returns>
        public FsmBase[] GetAllFsms()
        {
            int index = 0;

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

            return(results);
        }
예제 #5
0
        private bool InternalDestroyFsm(string fullName)
        {
            FsmBase fsm = null;

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

            return(false);
        }