Example #1
0
        public NetworkStateManagementGame  ()  
#endif
		{
			Content.RootDirectory = "Content";

			graphics = new GraphicsDeviceManager (this);            
#if ANDROID
            graphics.IsFullScreen = true;
#else
            graphics.PreferredBackBufferWidth = 1067;
			graphics.PreferredBackBufferHeight = 600;
#endif

			// Create components.
			screenManager = new ScreenManager (this);

			Components.Add (screenManager);
			Components.Add (new MessageDisplayComponent (this));
			Components.Add (new GamerServicesComponent (this));

			// Activate the first screens.
			screenManager.AddScreen (new BackgroundScreen (), null);
			screenManager.AddScreen (new MainMenuScreen (), null);

			// Listen for invite notification events.
			NetworkSession.InviteAccepted += (sender, e) => NetworkSessionComponent.InviteAccepted (screenManager, e);

			// To test the trial mode behavior while developing your game,
			// uncomment this line:

			// Guide.SimulateTrialMode = true;
		}
Example #2
0
        /// <summary>
        /// The main game constructor.
        /// </summary>
        public NetworkStateManagementGame()
        {
            Content.RootDirectory = "Content";

            graphics = new GraphicsDeviceManager(this);

            // Create components.
            screenManager = new ScreenManager(this);

            Components.Add(screenManager);
            Components.Add(new MessageDisplayComponent(this));
            Components.Add(new GamerServicesComponent(this));

            // Activate the first screens.
            screenManager.AddScreen(new BackgroundScreen(), null);
            screenManager.AddScreen(new MainMenuScreen(), null);

            // Listen for invite notification events.
            NetworkSession.InviteAccepted += (sender, e) => NetworkSessionComponent.InviteAccepted(screenManager, e);

            // To test the trial mode behavior while developing your game,
            // uncomment this line:

            // Guide.SimulateTrialMode = true;

            if (NetworkStateManagementGame.MainGame == null) NetworkStateManagementGame.MainGame = this;
        }
Example #3
0
		/// <summary>
		/// Activates the loading screen.
		/// </summary>
		public static void Load (ScreenManager screenManager, bool loadingIsSlow,
				PlayerIndex? controllingPlayer,
				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, controllingPlayer);
		}
Example #4
0
        // Конструктор
        public Game1()
        {
            graphics = new GraphicsDeviceManager(this);
            graphics.PreferredBackBufferWidth = SizeScreen.Width;
            graphics.PreferredBackBufferHeight = SizeScreen.Height;

            ///////////////////////////////////////////////////////////////////////////////////
              //// Graphics.PreferredBackBufferFormat = SurfaceFormat.HalfSingle;   дуже обережно ж цим!!!
               //////////////////////////////////////////////////////////////////////////////////////////

            Content.RootDirectory = "Bin";

            screenManager = new ScreenManager(this);
            Components.Add(screenManager);
            Components.Add(new MessageDisplayComponent(this));
              //  Components.Add(new GamerServicesComponent(this));

            screenManager.AddScreen(new BackgroundScreen(), null);

            songLiberty.musicLevel = new Song[5];
            background = new Texture2D[5];

            SetSetting = new Setting();
        }
        /// <summary>
        /// Public method called when the user wants to leave the network session.
        /// Displays a confirmation message box, then disposes the session, removes
        /// the NetworkSessionComponent, and returns them to the main menu screen.
        /// </summary>
        public static void LeaveSession(ScreenManager screenManager,
                                        PlayerIndex playerIndex)
        {
            NetworkSessionComponent self = FindSessionComponent(screenManager.Game);

            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.LeaveSession();
                };

                screenManager.AddScreen(confirmMessageBox, playerIndex);
            }
        }
Example #6
0
        /// <summary>
        /// Internal method for leaving the network session. This disposes the
        /// session, removes the NetworkSessionComponent, and returns the user
        /// to the main menu screen.
        /// </summary>
        void LeaveSession()
        {
            // Destroy this NetworkSessionComponent.
            Dispose();

            // 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 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
            // intermediate screens, returning them to the existing MainMenuScreen
            // instance without bothering to reload everything. 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 MainMenuScreen. 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 via the LoadingScreen.

            GameScreen[] screens = screenManager.GetScreens();

            // Look for the MainMenuScreen.
            for (int i = 0; i < screens.Length; i++)
            {
                if (screens[i] is MainMenuScreen)
                {
                    // 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, null);
                    }

                    return;
                }
            }

            // If we didn't find an existing MainMenuScreen, reload everything.
            // The why-did-the-session-end message box will be displayed after
            // the loading screen has completed.
            LoadingScreen.Load(screenManager, false, null, new BackgroundScreen(),
                               new MainMenuScreen(),
                               messageBox);
        }