Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using Microsoft.Xna.Framework;
- using Microsoft.Xna.Framework.Audio;
- using Microsoft.Xna.Framework.Content;
- using Microsoft.Xna.Framework.GamerServices;
- using Microsoft.Xna.Framework.Graphics;
- using Microsoft.Xna.Framework.Input;
- using Microsoft.Xna.Framework.Media;
- namespace GameStates
- {
- class StateManager
- {
- private List<GameState> gamestates = new List<GameState>();
- public void addState(ContentManager theContentManager, GameState newstate, string title, StateManager tempmanager)
- {
- newstate.Init(title, tempmanager);
- newstate.loadContent(theContentManager);
- gamestates.Add(newstate);
- }
- public void changeState(string title)
- {
- foreach (GameState state in gamestates)
- {
- if (state.getActive())
- {
- state.toggleActive();
- }
- if (title.Equals(state.getTitle()))
- {
- state.toggleActive();
- }
- }
- }
- public void active(SpriteBatch spritebatch)
- {
- foreach (GameState state in gamestates)
- {
- if (state.getActive())
- {
- state.Update();
- state.Draw(spritebatch);
- }
- }
- }
- public GameState getActive()
- {
- foreach (GameState state in gamestates)
- {
- if (state.getActive())
- {
- return state;
- }
- }
- return null;
- }
- }
- }
Add Comment
Please, Sign In to add comment