예제 #1
0
    /// <summary>
    /// 跳向指定状态
    /// </summary>
    public FSMBase MoveState(string name)
    {
        if (!IsContainState(name))
        {
            return(null);
        }

        lastState = currentState;
        if (currentState != null)
        {
            currentState.OnExit();
        }

        currentState = GetState(name);

        currentState.OnEnter();

        return(currentState);
    }
예제 #2
0
    public void ChangeState(E_FSM_State_Type _state, params object[] args)
    {
        //没有这个状态 或 就是当前状态 就退出
        if (!m_allState.ContainsKey(_state) || _state == m_curState.state)
        {
            return;
        }
        if (m_curState == null)
        {
            return;
        }
        //本次状态退出
        m_curState.OnExit(args);
        //退出后把本次状态设为前一个状态
        m_priousState = m_curState;
        //根据想要更改的状态 去字典找 并设为当前状态
        m_curState = m_allState[_state];

        m_curState.OnEnter(args);
    }