예제 #1
0
        /// <summary>
        /// 切换状态
        /// </summary>
        /// <param name="_stateName"></param>
        public void ChangeState(int _stateName, IFsmStateParam _param = null)
        {
            if (!m_FsmList.IsContainsKey(_stateName))
            {
                Debug.LogFormat("跳转失败! 要跳转的状态不存在: {0}", _stateName);
                return;
            }

            if (_stateName == m_CurState)
            {
                Debug.Log("跳转失败! 不能跳转到当前状态");
                return;
            }

            m_CurStateFsm?.OnFinishState();
            m_PreState = m_CurState;

            m_CurStateFsm = m_FsmList[_stateName];
            m_CurState    = _stateName;
            m_CurStateFsm.OnInitState(_param);
            Debug.LogFormat("状态跳转:{0} => {1}", m_PreState, m_CurState);
        }