Ejemplo n.º 1
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);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Draws the loading screen.
        /// </summary>
        public override void Draw(GameTime gameTime)
        {
            // If we are the only active screen, that means all the previous screens
            // must have finished transitioning off. We check for this in the Draw
            // method, rather than in Update, because it isn't enough just for the
            // screens to be gone: in order for the transition to look good we must
            // have actually drawn a frame without them before we perform the load.
            if ((ScreenState == ScreenState.Active) &&
                (ScreenManager.GetScreens().Length == 1))
            {
                otherScreensAreGone = true;
            }

            // The gameplay screen takes a while to load, so we display a loading
            // message while that is going on, but the menus load very quickly, and
            // it would look silly if we flashed this up for just a fraction of a
            // second while returning from the game to the menus. This parameter
            // tells us how long the loading is going to take, so we know whether
            // to bother drawing the message.
            if (loadingIsSlow)
            {
                SpriteBatch spriteBatch = ScreenManager.SpriteBatch;
                SpriteFont font = ScreenManager.Font;

                string message = Resources.Loading;

                // Center the text in the viewport.
                Viewport viewport = ScreenManager.GraphicsDevice.Viewport;
                Vector2 viewportSize = new Vector2(viewport.Width, viewport.Height);
                Vector2 textSize = font.MeasureString(message);
                Vector2 textPosition = (viewportSize - textSize) / 2;

                Color color = new Color(255, 255, 255, TransitionAlpha);

                // Animate the number of dots after our "Loading..." message.
                loadAnimationTimer += gameTime.ElapsedGameTime;

                int dotCount = (int)(loadAnimationTimer.TotalSeconds * 5) % 10;
                    
                message += new string('.', dotCount);

                // Draw the text.
                spriteBatch.Begin();
                spriteBatch.DrawString(font, message, textPosition, color);
                spriteBatch.End();
            }
        }
Ejemplo n.º 3
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);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Draws the background screen.
        /// </summary>
        public override void Draw(GameTime gameTime)
        {
            SpriteBatch spriteBatch = ScreenManager.SpriteBatch;
            Viewport    viewport    = ScreenManager.GraphicsDevice.Viewport;
            Rectangle   fullscreen  = new Rectangle(0, 0, viewport.Width, viewport.Height);
            byte        fade        = TransitionAlpha;

            spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend);

            spriteBatch.Draw(backgroundTexture, fullscreen,
                             new Color(fade, fade, fade));

            try
            {
                if (ScreenManager.GetScreens().Length <= 2)
                {
                    for (int i = 0; i < Gamer.SignedInGamers.Count; i++)
                    {
                        Gamer.SignedInGamers[i].Presence.PresenceMode = GamerPresenceMode.AtMenu;
                    }

                    //menu screen updates should go right under this!
                    //and drawing code too!! wow 2 in 1!

                    //
                }



                //
#if WINDOWS
                spriteBatch.DrawString(ScreenManager.Font, "v" + Global_Variables.version, new Vector2(1210, 690), Color.White, 0, Vector2.Zero, .6f, SpriteEffects.None, 0);
                #region Old entering code

                if (Guide.IsTrialMode == false)
                {
                    Microsoft.Xna.Framework.Input.GamePadState gamepad1 =
                        Microsoft.Xna.Framework.Input.GamePad.GetState(PlayerIndex.One);
                    Microsoft.Xna.Framework.Input.GamePadState gamepad2 =
                        Microsoft.Xna.Framework.Input.GamePad.GetState(PlayerIndex.Two);
                    Microsoft.Xna.Framework.Input.GamePadState gamepad3 =
                        Microsoft.Xna.Framework.Input.GamePad.GetState(PlayerIndex.Three);
                    Microsoft.Xna.Framework.Input.GamePadState gamepad4 =
                        Microsoft.Xna.Framework.Input.GamePad.GetState(PlayerIndex.Four);
                    int numberplayersconnected = 0;
                    if (gamepad1.IsConnected)
                    {
                        numberplayersconnected++;
                    }
                    if (gamepad2.IsConnected)
                    {
                        numberplayersconnected++;
                    }
                    if (gamepad3.IsConnected)
                    {
                        numberplayersconnected++;
                    }
                    if (gamepad4.IsConnected)
                    {
                        numberplayersconnected++;
                    }
                    if (numberplayersconnected > 1)
                    {
                        if (gamepad1.IsConnected &&
                            player1isplaying == false)
                        {
                            spriteBatch.DrawString(ScreenManager.Font
                                                   ,
                                                   "\n\rPlayer 1: Press X To Enter!",
                                                   new Vector2(Convert.ToInt32(ScreenManager.GraphicsDevice.Viewport.Width * .6)
                                                               ,
                                                               ScreenManager.GraphicsDevice.Viewport.TitleSafeArea.Y + 5
                                                               ),

                                                   Color.LightGreen);
                        }

                        else if (gamepad1.IsConnected && player1isplaying)
                        {
                            spriteBatch.DrawString(ScreenManager.Font
                                                   ,
                                                   "\n\rPlayer 1: Press Y To Leave!",
                                                   new Vector2(Convert.ToInt32(ScreenManager.GraphicsDevice.Viewport.Width * .6)
                                                               ,
                                                               ScreenManager.GraphicsDevice.Viewport.TitleSafeArea.Y + 5
                                                               ),

                                                   Color.LightGreen);
                        }
                        if (gamepad2.IsConnected &&
                            player2isplaying == false)
                        {
                            spriteBatch.DrawString(ScreenManager.Font
                                                   ,
                                                   "\n\r\n\rPlayer 2: Press X To Enter!",
                                                   new Vector2(Convert.ToInt32(ScreenManager.GraphicsDevice.Viewport.Width * .6)
                                                               ,
                                                               ScreenManager.GraphicsDevice.Viewport.TitleSafeArea.Y + 5
                                                               ),

                                                   Color.LightBlue);
                        }
                        else if (gamepad2.IsConnected && player2isplaying)
                        {
                            spriteBatch.DrawString(ScreenManager.Font
                                                   ,
                                                   "\n\r\n\rPlayer 2: Press Y To Leave!",
                                                   new Vector2(Convert.ToInt32(ScreenManager.GraphicsDevice.Viewport.Width * .6)
                                                               ,
                                                               ScreenManager.GraphicsDevice.Viewport.TitleSafeArea.Y + 5
                                                               ),

                                                   Color.LightBlue);
                        }
                        if (gamepad3.IsConnected &&
                            player3isplaying == false)
                        {
                            spriteBatch.DrawString(ScreenManager.Font
                                                   ,
                                                   "\n\r\n\r\n\rPlayer 3: Press X To Enter!",
                                                   new Vector2(Convert.ToInt32(ScreenManager.GraphicsDevice.Viewport.Width * .6)
                                                               ,
                                                               ScreenManager.GraphicsDevice.Viewport.TitleSafeArea.Y + 5
                                                               ),

                                                   Color.Yellow);
                        }
                        else if (gamepad3.IsConnected && player3isplaying)
                        {
                            spriteBatch.DrawString(ScreenManager.Font
                                                   ,
                                                   "\n\r\n\r\n\rPlayer 3: Press Y To Leave!",
                                                   new Vector2(Convert.ToInt32(ScreenManager.GraphicsDevice.Viewport.Width * .6)
                                                               ,
                                                               ScreenManager.GraphicsDevice.Viewport.TitleSafeArea.Y + 5
                                                               ),

                                                   Color.Yellow);
                        }
                        if (gamepad4.IsConnected &&
                            player4isplaying == false)
                        {
                            spriteBatch.DrawString(ScreenManager.Font
                                                   ,
                                                   "\n\r\n\r\n\r\n\rPlayer 4: Press X To Enter!",
                                                   new Vector2(Convert.ToInt32(ScreenManager.GraphicsDevice.Viewport.Width * .6)
                                                               ,
                                                               ScreenManager.GraphicsDevice.Viewport.TitleSafeArea.Y + 5
                                                               ),

                                                   Color.Purple);
                        }
                        else if (gamepad4.IsConnected && player4isplaying)
                        {
                            spriteBatch.DrawString(ScreenManager.Font
                                                   ,
                                                   "\n\r\n\r\n\r\n\rPlayer 4: Press Y To Leave!",
                                                   new Vector2(Convert.ToInt32(ScreenManager.GraphicsDevice.Viewport.Width * .6)
                                                               ,
                                                               ScreenManager.GraphicsDevice.Viewport.TitleSafeArea.Y + 5
                                                               ),

                                                   Color.White);
                        }
                        if (gamepad1.IsButtonDown(Microsoft.Xna.Framework.Input.Buttons.X))
                        {
                            player1isplaying = true;
                        }
                        if (gamepad2.IsButtonDown(Microsoft.Xna.Framework.Input.Buttons.X))
                        {
                            player2isplaying = true;
                        }
                        if (gamepad3.IsButtonDown(Microsoft.Xna.Framework.Input.Buttons.X))
                        {
                            player3isplaying = true;
                        }
                        if (gamepad4.IsButtonDown(Microsoft.Xna.Framework.Input.Buttons.X))
                        {
                            player4isplaying = true;
                        }

                        if (gamepad1.IsButtonDown(Microsoft.Xna.Framework.Input.Buttons.Y))
                        {
                            player1isplaying = false;
                        }
                        if (gamepad2.IsButtonDown(Microsoft.Xna.Framework.Input.Buttons.Y))
                        {
                            player2isplaying = false;
                        }
                        if (gamepad3.IsButtonDown(Microsoft.Xna.Framework.Input.Buttons.Y))
                        {
                            player3isplaying = false;
                        }
                        if (gamepad4.IsButtonDown(Microsoft.Xna.Framework.Input.Buttons.Y))
                        {
                            player4isplaying = false;
                        }
                    }
                }

                #endregion
#endif
            }
            catch { }


            spriteBatch.End();
        }