// Constructor(s) public GameStateManagerArgs() { DefaultCondition = new GameStateCondition() { BeginFrame = true, Step = true, Draw = true }; }
// Constructor(s) internal GameStateManager(GameEngine engine, GameStateManagerArgs args) { // _defaultCondition = new GameStateCondition(args.DefaultCondition); // _states = new Dictionary <GameState, GameStateCondition>(); // _engine = engine; }
public bool RemoveState(GameState state) { // If the state exists if (_states.ContainsKey(state)) { // Disable state GameStateCondition con = _states[state]; if (con.BeginFrame) // BeginFrame { DisableBeginFrame(state); } if (con.Step) // Step { DisableStep(state); } if (con.Draw) // Draw { DisableDraw(state); } // Unload UnloadContent(state); // Remove the state _beginFrame += () => { _states.Remove(state); state.OnRemoved(); }; // Debug GameConsole.WriteLine(string.Format("GameState Removed: \"{0}\"", state.GetType().ToString())); // State found and removed (Success) return(true); } // State not found (Fail) GameConsole.WriteLine(string.Format("{0}: Tried to remove GameState \"{1}\"", this.GetType().Name, state.GetType().ToString()), GameConsole.MessageType.Important); // Debug return(false); }
public void AddState(GameState state, GameStateCondition con) { // Cant add the same state multiple times if (_states.ContainsKey(state)) { return; } // Add state _states.Add(state, new GameStateCondition()); // Set up state state.Setup(_engine); // Initialize state state.Initialize(); // Load resources LoadState(state); // Enable custom settings if (con.BeginFrame) // BeginFrame { EnableBeginFrame(state); } if (con.Step) // Step { EnableStep(state); } if (con.Draw) // Draw { EnableDraw(state); } // Debug GameConsole.WriteLine(string.Format("GameState Added: \"{0}\"", state.GetType().ToString()), GameConsole.MessageType.Important); }
public GameStateManagerArgs(GameStateManagerArgs args) { DefaultCondition = new GameStateCondition(args.DefaultCondition); }
internal GameStateCondition(GameStateCondition con) { BeginFrame = con.BeginFrame; Step = con.Step; Draw = con.Draw; }