public override void OnDisabled(GameState nextState) { //Dispose all components related to the Game scope GameScope.CurrentGameScope.Dispose(); //Create a new Scope GameScope.CreateNewScope(); base.OnDisabled(nextState); }
public override void OnEnabled(GameState previousState) { var menu = _ioc.Get <MainMenuComponent>(); menu.CreditsPressed += MenuCreditsPressed; menu.SinglePlayerPressed += MenuSinglePlayerPressed; menu.MultiplayerPressed += MenuMultiplayerPressed; menu.EditorPressed += MenuEditorPressed; menu.SettingsButtonPressed += MenuSettingsButtonPressed; menu.LogoutPressed += MenuLogoutPressed; menu.ExitPressed += MenuExitPressed; var guiManager = _ioc.Get <GuiManager>(); if (_vars.DisposeGameComponents) { _vars.DisposeGameComponents = false; var inputManager = _ioc.Get <InputsManager>(); inputManager.MouseManager.MouseCapture = false; if (!string.IsNullOrEmpty(_vars.MessageOnExit)) { guiManager.MessageBox(_vars.MessageOnExit, "Information"); _vars.MessageOnExit = null; } var soundEngine = _ioc.Get <ISoundEngine>(); soundEngine.StopAllSounds(); //Dispose all components related to the Game scope GameScope.CurrentGameScope.Dispose(); //Create a new Scope GameScope.CreateNewScope(); } base.OnEnabled(previousState); }