//Audio audioHelper, Cue mystery) /// <summary> /// Constructor fills in the menu contents. /// </summary> public CreateOrFindSessionScreen(ScreenManager screenManager, NetworkSessionType sessionType, AudioManager audioManager) : base(GetMenuTitle(sessionType), false) { networkHelper = new NetworkHelper(); networkInterface = new NetworkInterface(); networkInterface.InitNetwork(screenManager.Game); this.audioManager = audioManager; //this.audioHelper = audioHelper; //this.mystery = mystery; this.sessionType = sessionType; // Create our menu entries. MenuEntry createSessionMenuEntry = new MenuEntry(Resources.CreateSession); MenuEntry findSessionsMenuEntry = new MenuEntry(Resources.FindSessions); MenuEntry backMenuEntry = new MenuEntry(Resources.Back); // Hook up menu event handlers. createSessionMenuEntry.Selected += CreateSessionMenuEntrySelected; findSessionsMenuEntry.Selected += FindSessionsMenuEntrySelected; backMenuEntry.Selected += OnCancel; // Add entries to the menu. MenuEntries.Add(createSessionMenuEntry); MenuEntries.Add(findSessionsMenuEntry); MenuEntries.Add(backMenuEntry); }
/// <summary> /// The main game constructor. /// </summary> public TRA_Game() { Content.RootDirectory = "Content"; graphics = new GraphicsDeviceManager(this); graphics.PreferredBackBufferWidth = 1067; graphics.PreferredBackBufferHeight = 600; // Create components. screenManager = new ScreenManager(this); Components.Add(screenManager); Components.Add(new MessageDisplayComponent(this)); Components.Add(new GamerServicesComponent(this)); //Components.Add(new VersionDrawer(this, 0.01f, screenManager.Font)); audioManager = new AudioManager(this); audioManager.LoadSong("mystery"); audioManager.LoadSound("famas-1"); Services.AddService(typeof(AudioManager), audioManager); // Activate the first screens. screenManager.AddScreen(new SplashScreen()); //screenManager.AddScreen(new BackgroundScreen(false)); //screenManager.AddScreen(new MainMenuScreen(false, null)); //Update the audio //audioHelper = new Audio("Content\\TRA_Game.xgs"); //audioHelper.Update(); }
public override void LoadContent() { this.audioManager = (AudioManager)ScreenManager.Game.Services.GetService(typeof(AudioManager)); if (this.audioManager == null) throw new NullReferenceException("No audio Manager"); this.audioManager.PlaySong("mystery", true); base.LoadContent(); }
/// <summary> /// Loads graphics content for this screen. The background texture is quite /// big, so we use our own local ContentManager to load it. This allows us /// to unload before going from the menus into the game itself, wheras if we /// used the shared ContentManager provided by the Game class, the content /// would remain loaded forever. /// </summary> public override void LoadContent() { if (content == null) content = new ContentManager(ScreenManager.Game.Services, "Content"); this.audioManager = (AudioManager)this.ScreenManager.Game.Services.GetService(typeof(AudioManager)); texture = content.Load<Texture2D>("splash"); ScreenManager.Game.Components.Add(new VersionDrawer(ScreenManager.Game, 0.01f)); }
public override void LoadContent() { this.audioManager = (AudioManager)ScreenManager.Game.Services.GetService(typeof(AudioManager)); base.LoadContent(); }
/// <summary> /// Loads graphics content used by the lobby screen. /// </summary> public override void LoadContent() { ContentManager content = ScreenManager.Game.Content; isReadyTexture = content.Load<Texture2D>("chat_ready"); hasVoiceTexture = content.Load<Texture2D>("chat_able"); isTalkingTexture = content.Load<Texture2D>("chat_talking"); voiceMutedTexture = content.Load<Texture2D>("chat_mute"); this.audioManager = (AudioManager)ScreenManager.Game.Services.GetService(typeof(AudioManager)); }
//Audio audioHelper) void LeaveSessionFromGame(AudioManager audioManager) { // Remove the NetworkSessionComponent. Game.Components.Remove(this); // Remove the NetworkSession service. Game.Services.RemoveService(typeof(NetworkSession)); // Dispose the NetworkSession. networkSession.Dispose(); networkSession = null; // If we have a sessionEndMessage string explaining why the session has // ended (maybe this was a network disconnect, or perhaps the host kicked // us out?) create a message box to display this reason to the user. MessageBoxScreen messageBox; if (!string.IsNullOrEmpty(sessionEndMessage)) messageBox = new MessageBoxScreen(sessionEndMessage, false); else messageBox = null; // At this point we normally want to return the user all the way to the // main menu screen. But what if they just joined a session? In that case // they went through this flow of screens: // // - MainMenuScreen // - CreateOrFindSessionsScreen // - JoinSessionScreen (if joining, skipped if creating a new session) // - LobbyScreeen // // If we have these previous screens on the history stack, and the user // backs out of the LobbyScreen, the right thing is just to pop off the // LobbyScreen and JoinSessionScreen, returning them to the // CreateOrFindSessionsScreen (we cannot just back up to the // JoinSessionScreen, because it contains search results that will no // longer be valid). But if the user is in gameplay, or has been in // gameplay and then returned to the lobby, the screen stack will have // been emptied. // // To do the right thing in both cases, we scan through the screen history // stack looking for a CreateOrFindSessionScreen. If we find one, we pop // any subsequent screens so as to return back to it, while if we don't // find it, we just reset everything and go back to the main menu. GameScreen[] screens = screenManager.GetScreens(); // Look for the CreateOrFindSessionsScreen. for (int i = 0; i < screens.Length; i++) { if (screens[i] is CreateOrFindSessionScreen) { // If we found one, pop everything since then to return back to it. for (int j = i + 1; j < screens.Length; j++) screens[j].ExitScreen(); // Display the why-did-the-session-end message box. if (messageBox != null) screenManager.AddScreen(messageBox); return; } } // If we didn't find a CreateOrFindSessionsScreen, reset everything and // go back to the main menu. The why-did-the-session-end message box // will be displayed after the loading screen has completed. LoadingScreen.Load(screenManager, false, new BackgroundScreen(NetworkSessionComponent.Level.shipMap), new MainMenuScreen(), messageBox); }
// Audio audioHelper) public static void LeaveSessionFromGame(ScreenManager screenManager, AudioManager audioManager) { // Search through Game.Components to find the NetworkSessionComponent. foreach (IGameComponent component in screenManager.Game.Components) { NetworkSessionComponent self = component as NetworkSessionComponent; if (self != null) { // Display a message box to confirm the user really wants to leave. string message; if (self.networkSession.IsHost) message = Resources.ConfirmEndSession; else message = Resources.ConfirmLeaveSession; MessageBoxScreen confirmMessageBox = new MessageBoxScreen(message); // Hook the messge box ok event to actually leave the session. confirmMessageBox.Accepted += delegate { self.LeaveSessionFromGame(audioManager);//audioHelper); }; screenManager.AddScreen(confirmMessageBox); break; } } }