Beispiel #1
0
 public void PerformGlobalTransition(eFSMTransition t)
 {
     if (m_GlobalMap.ContainsKey(t))
     {
         m_currentState.DoBeforeLeave(m_Data);
         m_currentState = m_GlobalMap[t];
         m_currentState.DoBeforeEnter(m_Data);
         m_currentStateID = m_currentState.m_StateID;
     }
 }
Beispiel #2
0
 /// <summary>
 /// 执行切换下一个状态
 /// </summary>
 /// <param name="transition">Transition.</param>
 public void PerformTransition(FSMTransition transition)
 {
     if (transition != null && currentState != null)
     {
         FSMStateId nextStateId = currentState.GetStateId(transition);
         if (nextStateId != FSMStateId.Empty)
         {
             FSMState state;
             stateDict.TryGetValue(nextStateId, out state);
             currentState.DoBeforeLeave();
             currentState = state;
             state.DoBeforeEnter();
         }
     }
 }
Beispiel #3
0
 /// <summary>
 /// 执行切换下一个状态
 /// </summary>
 /// <param name="transition">Transition.</param>
 public void PerformTransition(FSMTransition transition, params object[] pars)
 {
     if (transition != null && currentState != null)
     {
         FSMStateId nextStateId = currentState.GetStateId(transition);
         if (nextStateId != FSMStateId.Empty)
         {
             FSMState state;
             stateDict.TryGetValue(nextStateId, out state);
             currentState.DoBeforeLeave();
             currentState = state;
             state.DoBeforeEnter(pars);
             if (playerType == PlayerType.Self)
             {
                 SyncTransitionRequest.Instance.SendSyncTransitionRequest(transition, pars);
             }
         }
     }
 }
Beispiel #4
0
    public void ChangeState(Type newState)
    {
        if (!newState.IsSubclassOf(typeof(FSMState <T>)))
        {
            Debug.LogError("Trying to transition to incorrect type state");
            return;
        }

        if (statesList.ContainsKey(newState))
        {
            currentState.DoBeforeLeave();
            currentState = statesList[newState];
            currentState.DoBeforeEntering();
        }
        else
        {
            Debug.LogError("There is no state " + newState.ToString() + " in dictionary");
        }
    }