Пример #1
0
        /// <summary>
        /// Used to start the game. Game starts with the GameState added first
        /// and when this state ends it jumps to another in the list.
        /// </summary>
        public void StartGame()
        {
            if (m_States == null)
                throw new Exception("States wasn't initialized.");

            if (m_States.Count == 0)
                throw new Exception("States list is empty");

            m_CurrentState = m_States[0];
            StartState();
        }
Пример #2
0
 /// <summary>
 /// Used to add a GameState object to the game
 /// </summary>
 /// <param name="state">GameState you want to add</param>
 public void AddState(GameState state)
 {
     m_States.Add(state);
 }
Пример #3
0
 /// <summary>
 /// Used to remove the GameState from the game
 /// </summary>
 /// <param name="state">GameState object that you want to remove</param>
 public void RemoveState(GameState state)
 {
     m_States.Remove(state);
 }
Пример #4
0
 /// <summary>
 /// Must be called by the GameState to inform the game that 
 /// the new state should be started.
 /// </summary>
 public void StateEnded()
 {
     m_CurrentState.CleanUp();
     if (m_CurrentState is RepetetiveState)
     {
         if (((RepetetiveState)m_CurrentState).CheckCondition())
         {
             ((RepetetiveState)m_CurrentState).StartState();
             return;
         }
     }
     m_CurrentState = NextState();
     StartState();
 }