Exemplo n.º 1
0
    //--------------------------------------------------------------------------------------
    // PushState: A function to push a state onto the statemachine stack.
    //
    // Param:
    //		eStateIndex: An index for the state you want to push.
    //--------------------------------------------------------------------------------------
    void PushState(ETurnManagerStates eStateIndex)
    {
        // Check if there is anything on the current stack.
        if (m_CurrentStack.Count > 0)
        {
            // Run the onExit function for the top stack.
            m_CurrentStack.Peek().OnExit();
        }

        // Push the new state to the stack.
        m_CurrentStack.Push(m_asStateList[(int)eStateIndex]);

        // Run the onEnter function for the state on the top of the stack.
        m_CurrentStack.Peek().OnEnter();
    }
Exemplo n.º 2
0
    //--------------------------------------------------------------------------------------
    // ChangeState: Change the machine state, pop top of the stack and push the new state.
    //
    // Param:
    //      eStateIndex: An index for the state to change to.
    //--------------------------------------------------------------------------------------
    public void ChangeState(ETurnManagerStates eStateIndex)
    {
        // Check if there is anything on the current stack.
        if (m_CurrentStack.Count > 0)
        {
            // Pop the top state
            PopState();
        }

        // Set the current State value to eStateIndex
        m_eCurrentState = eStateIndex;

        // Push the newly seletec state.
        PushState(eStateIndex);
    }
Exemplo n.º 3
0
 //--------------------------------------------------------------------------------------
 // AddState: A function to add states to the statemachine array.
 //
 // Param:
 //		eStateIndex: An index for the state.
 //		sState: reference to the state you want to add.
 //--------------------------------------------------------------------------------------
 public void AddState(ETurnManagerStates eStateIndex, State sState)
 {
     // Insert the state into the state array.
     m_asStateList.Insert((int)eStateIndex, sState);
 }