Exemplo n.º 1
0
 /// <summary>Adds a game state to the game</summary>
 /// <param name="stateId">What you want this state to be called so that you can access it.</param>
 /// <param name="state">The reference to the game state object to be added.</param>
 public static void AddState(InterfaceGameState state)
 {
     if (StateExists(state.Id))
     {
         Output.ClearIndent();
         Output.WriteLine("ERROR!\nStateSystem.cs\\AddState(): " + state.Id + " already exits.");
         throw new StateSystemException("ERROR!\nStateSystem.cs\\AddState(): " + state.Id + " already exits.");
     }
     else
     {
         _stateDatabase.Add(state);
         Output.WriteLine("\"" + state.Id + "\" state loaded;");
     }
 }
Exemplo n.º 2
0
 /// <summary>Adds a game state to the game</summary>
 /// <param name="stateId">What you want this state to be called so that you can access it.</param>
 /// <param name="state">The reference to the game state object to be added.</param>
 public static void AddState(InterfaceGameState state)
 {
   if (StateExists(state.Id))
   {
     Output.ClearIndent();
     Output.WriteLine("ERROR!\nStateSystem.cs\\AddState(): " + state.Id + " already exits.");
     throw new StateSystemException("ERROR!\nStateSystem.cs\\AddState(): " + state.Id + " already exits.");
   }
   else
   {
     _stateDatabase.Add(state);
     Output.WriteLine("\"" + state.Id + "\" state loaded;");
   }
 }
Exemplo n.º 3
0
        /// <summary>Select the current state to be updated and rendered.</summary>
        /// <param name="stateId">The name associated with the state (what you caled it when you added it).</param>
        public static void ChangeState(string stateId)
        {
            InterfaceGameState state;

            if (!TryGet(stateId, out state))
            {
                Output.ClearIndent();
                Output.WriteLine("ERROR: state \"" + stateId + "\" does not exits.");
                throw new StateSystemException("Attempting to change states to a non-existent state \"" + stateId + "\".");
            }
            else if (!state.IsReady)
            {
                Output.ClearIndent();
                Output.WriteLine("ERROR: state \"" + stateId + "\" is not ready to become the current state.");
                throw new StateSystemException("Attempting to change states to a state that has not been fully loaded \"" + stateId + "\".");
            }
            else
            {
                _currentState = _stateDatabase.Get <string>(stateId, _keyComparison);
                Output.WriteLine("\"" + stateId + "\" state selected;");
            }
        }
Exemplo n.º 4
0
 /// <summary>Tries to get a desired state, but returns a bool rather than crashing.</summary>
 /// <param name="stateId">The name of the state to get.</param>
 /// <param name="state">The reference to the state.</param>
 /// <returns>Whether or not it could get the value.</returns>
 public static bool TryGet(string stateId, out InterfaceGameState state)
 {
     return(_stateDatabase.TryGet <string>(stateId, _keyComparison, out state));
 }
Exemplo n.º 5
0
 /// <summary>Select the current state to be updated and rendered.</summary>
 /// <param name="stateId">The name associated with the state (what you caled it when you added it).</param>
 public static void ChangeState(string stateId)
 {
   InterfaceGameState state;
   if (!TryGet(stateId, out state))
   {
     Output.ClearIndent();
     Output.WriteLine("ERROR: state \"" + stateId + "\" does not exits.");
     throw new StateSystemException("Attempting to change states to a non-existent state \"" + stateId + "\".");
   }
   else if (!state.IsReady)
   {
     Output.ClearIndent();
     Output.WriteLine("ERROR: state \"" + stateId + "\" is not ready to become the current state.");
     throw new StateSystemException("Attempting to change states to a state that has not been fully loaded \"" + stateId + "\".");
   }
   else
   {
     _currentState = _stateDatabase.Get(stateId);
     Output.WriteLine("\"" + stateId + "\" state selected;");
   }
 }
Exemplo n.º 6
0
 /// <summary>Tries to get a desired state, but returns a bool rather than crashing.</summary>
 /// <param name="stateId">The name of the state to get.</param>
 /// <param name="state">The reference to the state.</param>
 /// <returns>Whether or not it could get the value.</returns>
 public static bool TryGet(string stateId, out InterfaceGameState state)
 {
   try { state = _stateDatabase.Get(stateId); return true; }
   catch { state = null; return false; }
 }
Exemplo n.º 7
0
    /// <summary>Tries to get a desired state, but returns a bool rather than crashing.</summary>
    /// <param name="stateId">The name of the state to get.</param>
    /// <param name="state">The reference to the state.</param>
    /// <returns>Whether or not it could get the value.</returns>
    public static bool TryGet(string stateId, out InterfaceGameState state)
    {
       return _stateDatabase.TryGet<string>(stateId, _keyComparison, out state);

    }