Ejemplo n.º 1
0
        /// <summary>
        /// Begins the asynchronous process of joining a game from an invitation.
        /// </summary>
        void NetworkSession_InviteAccepted(object sender, InviteAcceptedEventArgs e)
        {
            if (Guide.IsTrialMode)
            {
                screenManager.invited = e.Gamer;

                string           message    = "Need to unlock full version before you can accept this invite.";
                MessageBoxScreen messageBox = new MessageBoxScreen(message);
                screenManager.AddScreen(messageBox);

                System.Console.WriteLine("Cannot accept invite yet because we're in trial mode");

                return;
            }

            // We will join the game from a method in this screen.
            MainMenuScreen mainMenu = null;

            // Keep the background screen and main menu screen but remove all others
            // to prepare for joining the game we were invited to.
            foreach (GameScreen screen in screenManager.GetScreens())
            {
                if (screen is BackgroundScreen)
                {
                    continue;
                }
                else if (screen is MainMenuScreen)
                {
                    mainMenu = screen as MainMenuScreen;
                }
                else
                {
                    // If there's an active network session, we'll need to end it
                    // before attempting to join a new one.
                    MethodInfo method = screen.GetType().GetMethod("EndSession");
                    if (method != null)
                    {
                        method.Invoke(screen, null);
                    }

                    // Now exit and remove this screen.
                    screen.ExitScreen();
                    screenManager.RemoveScreen(screen);
                }
            }

            // Now attempt to join the game to which we were invited!
            if (mainMenu != null)
            {
                mainMenu.JoinInvitedGame();
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Updates the loading screen.
        /// </summary>
        public override void Update(GameTime gameTime, bool otherScreenHasFocus,
                                    bool coveredByOtherScreen)
        {
            base.Update(gameTime, otherScreenHasFocus, coveredByOtherScreen);

            // If all the previous screens have finished transitioning
            // off, it is time to actually perform the load.
            if (otherScreensAreGone)
            {
                ScreenManager.RemoveScreen(this);

                loadNextScreen(this, EventArgs.Empty);
            }
        }