Exemple #1
0
        public void ChangeState <TState>(AFsm <T> fsm) where TState : AFsmState <T>
        {
            AFsm <T> fsmImplement = (AFsm <T>)fsm;

            if (fsmImplement == null)
            {
                throw new GameFrameworkException("FSM is invalid.");
            }

            fsmImplement.ChangeState <TState>();
        }
Exemple #2
0
        public void OnEvent(AFsm <T> fsm, object sender, int eventId, object userData)
        {
            FsmEventHandler <T> eventHandlers = null;

            if (m_EventHandlers.TryGetValue(eventId, out eventHandlers))
            {
                if (eventHandlers != null)
                {
                    eventHandlers(fsm, sender, userData);
                }
            }
        }
Exemple #3
0
        public void ChangeState(AFsm <T> fsm, Type stateType)
        {
            AFsm <T> fsmImplement = (AFsm <T>)fsm;

            if (fsmImplement == null)
            {
                throw new GameFrameworkException("FSM is invalid.");
            }

            if (stateType == null)
            {
                throw new GameFrameworkException("State type is invalid.");
            }

            if (!typeof(AFsmState <T>).IsAssignableFrom(stateType))
            {
                throw new GameFrameworkException(string.Format("State type '{0}' is invalid.", stateType.FullName));
            }

            fsmImplement.ChangeState(stateType);
        }
Exemple #4
0
 public virtual void OnDestroy(AFsm <T> fsm)
 {
     m_EventHandlers.Clear();
 }
Exemple #5
0
 public virtual void OnLeave(AFsm <T> fsm)
 {
 }
Exemple #6
0
 public virtual void OnUpdate(AFsm <T> fsm, float elapseSeconds)
 {
 }
Exemple #7
0
 public virtual void OnEnter(AFsm <T> fsm)
 {
 }
Exemple #8
0
 /// <summary>
 /// 有限状态机状态初始化时调用。
 /// </summary>
 /// <param name="fsm">有限状态机引用。</param>
 public virtual void OnInit(AFsm <T> fsm)
 {
 }