//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);
        }
Example #2
0
        /// <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();
        }
Example #3
0
        /// <summary>
        /// The constructor is private: loading screens should
        /// be activated via the static Load method instead.
        /// </summary>
        private LoadingScreen(ScreenManager screenManager, bool loadingIsSlow,
            GameScreen[] screensToLoad)
        {
            this.loadingIsSlow = loadingIsSlow;
            this.screensToLoad = screensToLoad;
            this.addNewScreen = false;

            TransitionOnTime = TimeSpan.FromSeconds(0.5);

            // If this is going to be a slow load operation, create a background
            // thread that will update the network session and draw the load screen
            // animation while the load is taking place.
            if (loadingIsSlow)
            {
                backgroundThread = new Thread(BackgroundWorkerThread);
                backgroundThreadExit = new ManualResetEvent(false);

                graphicsDevice = screenManager.GraphicsDevice;

                // Look up some services that will be used by the background thread.
                IServiceProvider services = screenManager.Game.Services;

                networkSession = (NetworkSession)services.GetService(
                                                            typeof(NetworkSession));

                messageDisplay = (IMessageDisplay)services.GetService(
                                                            typeof(IMessageDisplay));
            }
        }
        /// <summary>
        /// The constructor is private: external callers should use the Create method.
        /// </summary>
        NetworkSessionComponent(ScreenManager screenManager,
            NetworkSession networkSession)
            : base(screenManager.Game)
        {
            this.screenManager = screenManager;
            this.networkSession = networkSession;

            // Hook up our session event handlers.
            networkSession.GamerJoined += GamerJoined;
            networkSession.GamerLeft += GamerLeft;
            networkSession.SessionEnded += NetworkSessionEnded;
            networkSession.HostChanged += HostChanged;
        }
        /// <summary>
        /// Creates a new NetworkSessionComponent.
        /// </summary>
        public static void Create(ScreenManager screenManager,
            NetworkSession networkSession)
        {
            Game game = screenManager.Game;

            // Register this network session as a service.
            game.Services.AddService(typeof(NetworkSession), networkSession);

            // Create a NetworkSessionComponent, and add it to the Game.
            game.Components.Add(new NetworkSessionComponent(screenManager,
                                                            networkSession));
        }
        // 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;
                }
            }
        }
        /// <summary>
        /// Constructor fills in the menu contents.
        /// </summary>
        public SessionPropertiesScreen(ScreenManager screenManager, NetworkSessionType sessionType, //Audio audioHelper, Cue mystery
            bool createSession, NetworkHelper networkHelper)
            : base(Resources.SessionProperties + GetMenuTitle(sessionType), false)
        {
            if (networkHelper != null)
                this.networkHelper = networkHelper;
            else
                this.networkHelper = new NetworkHelper();
            networkInterface = new NetworkInterface();
            networkInterface.InitNetwork(screenManager.Game);

            //this.audioHelper = audioHelper;
            //this.mystery = mystery;
            this.sessionType = sessionType;
            //famas_1 = audioHelper.GetCue("famas-1");

            this.createSession = createSession;

            // Create our menu entries.
            MenuEntry levelMenuEntry = new MenuEntry(Resources.Level);
            MenuEntry gameModeMenuEntry = new MenuEntry(Resources.GameMode);
            MenuEntry weaponsMenuEntry = new MenuEntry(Resources.Weapons);
            MenuEntry scoreToWinMenuEntry = new MenuEntry(Resources.ScoreToWin);
            MenuEntry createSessionMenuEntry = new MenuEntry(Resources.CreateSession);
            MenuEntry searchSessionMenuEntry = new MenuEntry(Resources.SearchSessions);
            MenuEntry StartGameMenuEntry = new MenuEntry(Resources.StartGame);
            MenuEntry noofbotsMenuEntry = new MenuEntry(Resources.NumberOfBots);
            MenuEntry backMenuEntry = new MenuEntry(Resources.Back);

            if (createSession)
            {
                level = NetworkSessionComponent.Level.shipMap;
                gameModeType = NetworkSessionComponent.GameMode.DeathMatch;
                weaponsType = NetworkSessionComponent.Weapons.Normal;
                scoreToWinType = NetworkSessionComponent.ScoreToWin.One;
                noOfBots = NetworkSessionComponent.NoOfBots.Ten;
            }
            else
            {
                level = NetworkSessionComponent.Level.Any;
                gameModeType = NetworkSessionComponent.GameMode.Any;
                weaponsType = NetworkSessionComponent.Weapons.Any;
                scoreToWinType = NetworkSessionComponent.ScoreToWin.Any;
                noOfBots = NetworkSessionComponent.NoOfBots.Any;
            }

            // Hook up menu event handlers.
            levelMenuEntry.Selected += LevelMenuEntrySelected;
            gameModeMenuEntry.Selected += GameModeMenuEntrySelected;
            weaponsMenuEntry.Selected += WeaponsMenuEntrySelected;
            scoreToWinMenuEntry.Selected += ScoreToWinMenuEntrySelected;
            createSessionMenuEntry.Selected += CreateSessionMenuEntrySelected;
            searchSessionMenuEntry.Selected += SearchSessionsMenuEntrySelected;
            StartGameMenuEntry.Selected += StartGameMenuEntrySelected;
            noofbotsMenuEntry.Selected += NoOfBotsMenuEntry;
            backMenuEntry.Selected += OnCancel;

            // Add entries to the menu.
            MenuEntries.Add(levelMenuEntry);
            MenuEntries.Add(gameModeMenuEntry);
            MenuEntries.Add(weaponsMenuEntry);
            MenuEntries.Add(scoreToWinMenuEntry);
            MenuEntries.Add(noofbotsMenuEntry);

            if (sessionType != NetworkSessionType.Local)
                if (createSession)
                    MenuEntries.Add(createSessionMenuEntry);
                else
                    MenuEntries.Add(searchSessionMenuEntry);
            else
                MenuEntries.Add(StartGameMenuEntry);
            MenuEntries.Add(backMenuEntry);
        }
Example #8
0
        /// <summary>
        /// Activates the loading screen.
        /// </summary>
        public static void Load(ScreenManager screenManager, bool loadingIsSlow,
            params GameScreen[] screensToLoad)
        {
            // Tell all the current screens to transition off.
            foreach (GameScreen screen in screenManager.GetScreens())
                screen.ExitScreen();

            // Create and activate the loading screen.
            LoadingScreen loadingScreen = new LoadingScreen(screenManager,
                                                            loadingIsSlow,
                                                            screensToLoad);

            screenManager.AddScreen(loadingScreen);
        }