public static void SwitchState(int newState) { int args = 1; if (currentState != null) { args = currentState.args; } // If the new ID is not the current ID, then update the value if (newState != currentStateID) { currentStateID = newState; } // Change current state based on the ID switch (currentStateID) { case StateID.INTRO: music = introMusic; songChanged = true; currentState = new Intro(); break; case StateID.SPLASH: currentState = new Splash(); break; case StateID.PLAY: Random rand = new Random(); int song = rand.Next(0, 3); switch(song) { case 0: music = playMusic1; break; case 1: music = playMusic2; break; case 2: music = playMusic3; break; } songChanged = true; currentState = new Play(args); break; case StateID.MAIN_MENU: currentState = new Menu(); break; case StateID.CREDITS: currentState = new Credits(); break; case StateID.SELECT: currentState = new Select(); break; } currentState.Init(); currentState.Load(); }
public GameManager() { graphics = new GraphicsDeviceManager(this); Content.RootDirectory = "Content"; contentManager = Content; currentState = null; currentStateID = StateID.INTRO; }