/// <summary>
        /// Render loading screen
        /// </summary>
        public bool Render()
        {
            SpriteBatch textBatch = new SpriteBatch(BaseGame.Device);
            Vector2     position  = new Vector2((BaseGame.Width / 2) - 50, (BaseGame.Height / 2) - 20);

            for (int i = 0; i < loadingText.Length; i++)
            {
                string charStr    = new string(loadingText[i], 1);
                int    charHeight = (int)(position.Y + 7 * Math.Abs(Math.Sin((i / 4f) + (-BaseGame.TotalTime * 3))));
                TextureFont.WriteText((int)position.X, charHeight, charStr, Color.Red);

                position.X += TextureFont.GetTextWidth(charStr);
            }

            TextureFont.WriteTextCentered(BaseGame.Width / 2, (int)position.Y + 40, loadingStatus);

            return(RacingGameManager.ContentLoaded);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Render game screen. Called each frame.
        /// </summary>
        /// <returns>Bool</returns>
        public bool Render()
        {
            // This starts both menu and in game post screen shader!
            if (BaseGame.UsePostScreenShaders)
            {
                BaseGame.UI.PostScreenMenuShader.Start();
            }

            // Render background
            BaseGame.UI.RenderMenuBackground();
            BaseGame.UI.RenderBlackBar(160, 498 - 160);

            // Highscores header
            int posX = 10;
            int posY = 18;

            // UWP COMMENT OUT
            //if (Environment.OSVersion.Platform != PlatformID.Win32NT)
            //{
            //    posX += 36;
            //    posY += 26;
            //}
            BaseGame.UI.Headers.RenderOnScreenRelative1600(
                posX, posY, UIRenderer.HeaderHighscoresGfxRect);

            // Track selection
            int xPos       = BaseGame.XToRes(512 - 160 * 3 / 2 + 25);
            int yPos       = BaseGame.YToRes(182);
            int lineHeight = BaseGame.YToRes(27);

            // Beginner track
            bool inBox = Input.MouseInBox(new Rectangle(
                                              xPos, yPos, BaseGame.XToRes(125), lineHeight));

            TextureFont.WriteText(xPos, yPos, "Beginner",
                                  selectedLevel == 0 ? Color.Yellow :
                                  inBox ? Color.White : Color.LightGray);
            if (inBox && Input.MouseLeftButtonJustPressed)
            {
                Sound.Play(Sound.Sounds.ButtonClick);
                selectedLevel = 0;
            }
            xPos += BaseGame.XToRes(160 + 8);

            // Advanced track
            inBox = Input.MouseInBox(new Rectangle(
                                         xPos, yPos, BaseGame.XToRes(125), lineHeight));
            TextureFont.WriteText(xPos, yPos, "Advanced",
                                  selectedLevel == 1 ? Color.Yellow :
                                  inBox ? Color.White : Color.LightGray);
            if (inBox && Input.MouseLeftButtonJustPressed)
            {
                Sound.Play(Sound.Sounds.ButtonClick);
                selectedLevel = 1;
            }
            xPos += BaseGame.XToRes(160 + 30 - 8);

            // Expert track
            inBox = Input.MouseInBox(new Rectangle(
                                         xPos, yPos, BaseGame.XToRes(125), lineHeight));
            TextureFont.WriteText(xPos, yPos, "Expert",
                                  selectedLevel == 2 ? Color.Yellow :
                                  inBox ? Color.White : Color.LightGray);
            if (inBox && Input.MouseLeftButtonJustPressed)
            {
                Sound.Play(Sound.Sounds.ButtonClick);
                selectedLevel = 2;
            }

            // Also handle xbox controller input
            if (Input.GamePadLeftJustPressed ||
                Input.KeyboardLeftJustPressed)
            {
                Sound.Play(Sound.Sounds.ButtonClick);
                selectedLevel = (selectedLevel + 2) % 3;
            }
            else if (Input.GamePadRightJustPressed ||
                     Input.KeyboardRightJustPressed)
            {
                Sound.Play(Sound.Sounds.ButtonClick);
                selectedLevel = (selectedLevel + 1) % 3;
            }

            int xPos1 = BaseGame.XToRes(300);
            int xPos2 = BaseGame.XToRes(350);
            int xPos3 = BaseGame.XToRes(640);

            // Draw seperation line
            yPos = BaseGame.YToRes(208);
            BaseGame.DrawLine(
                new Point(xPos1, yPos),
                new Point(xPos3 + TextureFont.GetTextWidth("5:67:89"), yPos),
                new Color(192, 192, 192, 128));
            // And another one, looks better with 2 pixel height
            BaseGame.DrawLine(
                new Point(xPos1, yPos + 1),
                new Point(xPos3 + TextureFont.GetTextWidth("5:67:89"), yPos + 1),
                new Color(192, 192, 192, 128));

            yPos = BaseGame.YToRes(220);

            // Go through all highscores
            for (int num = 0; num < NumOfHighscores; num++)
            {
                Rectangle lineRect = new Rectangle(
                    0, yPos, BaseGame.Width, lineHeight);
                Color col = Input.MouseInBox(lineRect) ?
                            Color.White : new Color(200, 200, 200);
                TextureFont.WriteText(xPos1, yPos,
                                      (1 + num) + ".", col);
                TextureFont.WriteText(xPos2, yPos,
                                      highscores[selectedLevel, num].name, col);

                TextureFont.WriteGameTime(xPos3, yPos,
                                          highscores[selectedLevel, num].timeMilliseconds,
                                          Color.Yellow);

                yPos += lineHeight;
            }

            BaseGame.UI.RenderBottomButtons(true);

            if (Input.KeyboardEscapeJustPressed ||
                Input.GamePadBJustPressed ||
                Input.GamePadBackJustPressed ||
                Input.MouseLeftButtonJustPressed &&
                // Don't allow clicking on the controls to quit
                Input.MousePos.Y > yPos)
            {
                return(true);
            }

            return(false);
        }