예제 #1
0
        private Fsm InternalGetFsm(TypeNamePair typeNamePair)
        {
            Fsm fsm = null;

            if (_fsms.TryGetValue(typeNamePair, out fsm))
            {
                return(fsm);
            }

            return(null);
        }
예제 #2
0
        private bool InternalDestroyFsm(TypeNamePair typeNamePair)
        {
            Fsm fsm = null;

            if (_fsms.TryGetValue(typeNamePair, out fsm))
            {
                fsm.Shutdown();
                return(_fsms.Remove(typeNamePair));
            }

            return(false);
        }
예제 #3
0
        /// <summary>
        /// 创建有限状态机。
        /// </summary>
        /// <typeparam name="T">有限状态机持有者类型。</typeparam>
        /// <param name="name">有限状态机名称。</param>
        /// <param name="owner">有限状态机持有者。</param>
        /// <param name="states">有限状态机状态集合。</param>
        /// <returns>要创建的有限状态机。</returns>
        public IFsm <T> CreateFsm <T>(string name, T owner, List <FsmState <T> > states) where T : class
        {
            TypeNamePair typeNamePair = new TypeNamePair(typeof(T), name);

            if (HasFsm <T>(name))
            {
                throw new GameException(Utility.Text.Format("Already exist FSM '{0}'.", typeNamePair));
            }

            Fsm <T> fsm = Fsm <T> .Create(name, owner, states);

            _fsms.Add(typeNamePair, fsm);
            return(fsm);
        }
예제 #4
0
 private bool InternalHasFsm(TypeNamePair typeNamePair)
 {
     return(_fsms.ContainsKey(typeNamePair));
 }