Exemple #1
0
 /// <summary>
 /// 初始化有限状态机的名字和有限状态机的映射数据类型的构造方法
 /// </summary>
 /// <param name="t_FSMName"></param>
 /// <param name="t_IMapDataStructure"></param>
 public BaseFSM(IFSMOwner t_IFSMOwner, string t_FSMName, IMapDataStructure <string, BaseFSMState> t_IStateMapDataStructure, IMapDataStructure <string, BaseFSMCondition> t_IConditionMapDataStructure)
 {
     m_FSMName = t_FSMName ?? string.Empty;
     IStateMapDataStructure     = t_IStateMapDataStructure;
     IConditionMapDataStructure = t_IConditionMapDataStructure;
     OnInit(t_IFSMOwner);
 }
Exemple #2
0
        private void HandleEntityStateChanged(BaseEvent baseEvent)
        {
            SyncEvent e = ( SyncEvent )baseEvent;

            IFSMOwner entity = this.GetBio(e.targetId);

            entity.HandleEntityStateChanged(e.stateType, e.forceChange, e.stateParam);
        }
Exemple #3
0
 /// <summary>
 /// 状态机被轮询
 /// </summary>
 /// <param name="t_IModuleManager">状态机模块的管家</param>
 protected internal override void OnUpdate(IFSMOwner t_IFSMOwner)
 {
     if (IsRunning)         //如果状态机在运行
     {
         UpdateState();     //轮询更新状态
         UpdateCondition(); //轮询更新条件
     }
 }
Exemple #4
0
        /// <summary>
        /// 状态机被销毁
        /// </summary>
        /// <param name="t_IModuleManager">状态机模块的管家</param>
        protected internal override void OnDestroy(IFSMOwner t_IFSMOwner)
        {
            //TODO:状态机被销毁后

            IsRunning = false;

            //销毁所有的状态
            IStateMapDataStructure.Foreach((key, value) => {
                value.OnStateDestroy(this);
            });
            IStateMapDataStructure.Clear();

            //销毁所有的条件
            IConditionMapDataStructure.Foreach((key, value) => {
                value.OnConditionDestroy(this);
            });
            IConditionMapDataStructure.Clear();
        }
Exemple #5
0
 /// <summary>
 /// 状态机被销毁
 /// </summary>
 /// <param name="t_IModuleManager">状态机模块的管家</param>
 protected internal abstract void OnDestroy(IFSMOwner t_IFSMOwner);
Exemple #6
0
 /// <summary>
 /// 状态机被停止
 /// </summary>
 /// <param name="t_IModuleManager">状态机模块的管家</param>
 protected internal abstract void OnStop(IFSMOwner t_IFSMOwner);
Exemple #7
0
 /// <summary>
 /// 状态机被轮询
 /// </summary>
 /// <param name="t_IModuleManager">状态机模块的管家</param>
 protected internal abstract void OnUpdate(IFSMOwner t_IFSMOwner);
Exemple #8
0
 /// <summary>
 /// 状态机初始化
 /// </summary>
 /// <param name="t_IFSMOwner">状态机模块的管家</param>
 protected internal abstract void OnInit(IFSMOwner t_IFSMOwner);
Exemple #9
0
 /// <summary>
 /// 状态机被停止
 /// </summary>
 /// <param name="t_IModuleManager">状态机模块的管家</param>
 protected internal override void OnStop(IFSMOwner t_IFSMOwner)
 {
     //TODO:状态机关闭后
     IsRunning = false;
 }
Exemple #10
0
 /// <summary>
 /// 状态机启动
 /// </summary>
 protected internal override void OnStart(IFSMOwner t_IFSMOwner)
 {
     //TODO:状态机启动后
     IsRunning = true;
 }
Exemple #11
0
 /// <summary>
 /// 状态机初始化
 /// </summary>
 /// <param name="t_IModuleManager">状态机模块的管家</param>
 protected internal override void OnInit(IFSMOwner t_IFSMOwner)
 {
     //TODO:子类状态机可以在这里初始化一些东西
     IsRunning = true;
 }
Exemple #12
0
 /// <summary>
 /// 初始化有限状态机的构造方法
 /// </summary>
 /// <param name="t_FSMName"></param>
 /// <param name="t_FSMStates"></param>
 public FSM(IFSMOwner t_IFSMOwner, string t_FSMName, params BaseFSMState[] t_FSMStates) : base(t_IFSMOwner, t_FSMName, new FSMTrieMap <string, BaseFSMState>(), new FSMTrieMap <string, BaseFSMCondition>()) //子类选择的数据类型 可以为 FSMTrieMap<string,BaseFSMState>()
 {
     AddState(t_FSMStates);                                                                                                                                                                                  // 批量添加状态机条件
 }