Ejemplo n.º 1
0
 /// <summary>
 /// Render black bar
 /// </summary>
 /// <param name="yPos">Y position</param>
 /// <param name="height">Height</param>
 public void RenderBlackBar(int yPos, int height)
 {
     buttons.RenderOnScreen(
         BaseGame.CalcRectangle(0, yPos, 1024, height),
         BlackBarGfxRect,
         ColorHelper.ApplyAlphaToColor(Color.White, 0.85f));
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Render menu background
        /// </summary>
        public void RenderMenuBackground()
        {
            BaseGame.UI.UpdateCarInMenu();

            // Render game background
            RenderGameBackground();

            // And show track
            RenderMenuTrackBackground();

            // Render background with transparency
            // The background itself should be rendered before this ^^
            background.RenderOnScreen(
                BaseGame.ResolutionRect, BackgroundGfxRect,
                ColorHelper.ApplyAlphaToColor(Color.White, 0.85f));

            // Show RacingGame logo bouncing with the music
            float bounceSize = 1.005f +
                               (float)Math.Sin(BaseGame.TotalTime / 0.46f) * 0.045f *
                               (float)Math.Cos(BaseGame.TotalTime / 0.285f);

            background.RenderOnScreen(
                BaseGame.CalcRectangleWithBounce(362, 36, 601, 218, bounceSize),
                RacingGameLogoGfxRect);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Render game user interface
        /// </summary>
        /// <param name="currentGameTime">Current game time</param>
        /// <param name="bestLapTime">Best lap time</param>
        /// <param name="lapNumber">Lap number</param>
        /// <param name="speed">Speed</param>
        /// <param name="gear">Gear</param>
        /// <param name="trackName">Track name</param>
        /// <param name="top5LapTimes">Top 5 lap times</param>
        public void RenderGameUI(int currentGameTime, int bestLapTime,
                                 int lapNumber, float speed, int gear, float acceleration,
                                 string trackName, int[] top5LapTimes)
        {
            if (top5LapTimes == null)
            {
                throw new ArgumentNullException("top5LapTimes");
            }

            Color baseUIColor = Color.White;//ColorHelper.HalfAlpha;

            // If game is over, set speed, gear and acceleration to 0
            if (RacingGameManager.Player.GameOver)
            {
                speed        = 0;
                gear         = 1;
                acceleration = 0;
            }

            // More distance to the screen borders on the Xbox 360 to fit better into
            // the save region. Calculate all rectangles for each platform,
            // then they will be used the same way on both platforms.
#if XBOX360
            // Draw all boxes and background stuff
            Rectangle lapsRect = BaseGame.CalcRectangle1600(
                60, 46, LapsGfxRect.Width, LapsGfxRect.Height);
            ingame.RenderOnScreen(lapsRect, LapsGfxRect, baseUIColor);

            Rectangle timesRect = BaseGame.CalcRectangle1600(
                60, 46, CurrentAndBestGfxRect.Width, CurrentAndBestGfxRect.Height);
            timesRect.Y = BaseGame.Height - timesRect.Bottom;
            ingame.RenderOnScreen(timesRect, CurrentAndBestGfxRect, baseUIColor);

            Rectangle trackNameRect = BaseGame.CalcRectangle1600(
                60, 46, TrackNameGfxRect.Width, TrackNameGfxRect.Height);
            trackNameRect.X = BaseGame.Width - trackNameRect.Right;
            ingame.RenderOnScreen(trackNameRect, TrackNameGfxRect, baseUIColor);
            Rectangle top5Rect1 = BaseGame.CalcRectangle1600(
                60, 4, Best5GfxRect.Width, Best5GfxRect.Height);
            top5Rect1.X = trackNameRect.X;
            int top5Distance = top5Rect1.Y;
            top5Rect1.Y += trackNameRect.Bottom;
            ingame.RenderOnScreen(top5Rect1, Best5GfxRect, baseUIColor);
            Rectangle top5Rect2 = new Rectangle(top5Rect1.X,
                                                top5Rect1.Bottom + top5Distance, top5Rect1.Width, top5Rect1.Height);
            ingame.RenderOnScreen(top5Rect2, Best5GfxRect, baseUIColor);
            Rectangle top5Rect3 = new Rectangle(top5Rect1.X,
                                                top5Rect2.Bottom + top5Distance, top5Rect1.Width, top5Rect1.Height);
            ingame.RenderOnScreen(top5Rect3, Best5GfxRect, baseUIColor);
            Rectangle top5Rect4 = new Rectangle(top5Rect1.X,
                                                top5Rect3.Bottom + top5Distance, top5Rect1.Width, top5Rect1.Height);
            ingame.RenderOnScreen(top5Rect4, Best5GfxRect, baseUIColor);
            Rectangle top5Rect5 = new Rectangle(top5Rect1.X,
                                                top5Rect4.Bottom + top5Distance, top5Rect1.Width, top5Rect1.Height);
            ingame.RenderOnScreen(top5Rect5, Best5GfxRect, baseUIColor);

            Rectangle tachoRect = BaseGame.CalcRectangle1600(
                60, 46, TachoGfxRect.Width, TachoGfxRect.Height);
            tachoRect.X = BaseGame.Width - tachoRect.Right;
            tachoRect.Y = BaseGame.Height - tachoRect.Bottom;
#else
            // Draw all boxes and background stuff
            Rectangle lapsRect = BaseGame.CalcRectangle1600(
                10, 10, LapsGfxRect.Width, LapsGfxRect.Height);
            ingame.RenderOnScreen(lapsRect, LapsGfxRect, baseUIColor);

            Rectangle timesRect = BaseGame.CalcRectangle1600(
                10, 10, CurrentAndBestGfxRect.Width, CurrentAndBestGfxRect.Height);
            timesRect.Y = BaseGame.Height - timesRect.Bottom;
            ingame.RenderOnScreen(timesRect, CurrentAndBestGfxRect, baseUIColor);

            Rectangle trackNameRect = BaseGame.CalcRectangle1600(
                10, 10, TrackNameGfxRect.Width, TrackNameGfxRect.Height);
            trackNameRect.X = BaseGame.Width - trackNameRect.Right;
            ingame.RenderOnScreen(trackNameRect, TrackNameGfxRect, baseUIColor);
            Rectangle top5Rect1 = BaseGame.CalcRectangle1600(
                10, 4, Best5GfxRect.Width, Best5GfxRect.Height);
            top5Rect1.X = trackNameRect.X;
            int top5Distance = top5Rect1.Y;
            top5Rect1.Y += trackNameRect.Bottom;
            ingame.RenderOnScreen(top5Rect1, Best5GfxRect, baseUIColor);
            Rectangle top5Rect2 = new Rectangle(top5Rect1.X,
                                                top5Rect1.Bottom + top5Distance, top5Rect1.Width, top5Rect1.Height);
            ingame.RenderOnScreen(top5Rect2, Best5GfxRect, baseUIColor);
            Rectangle top5Rect3 = new Rectangle(top5Rect1.X,
                                                top5Rect2.Bottom + top5Distance, top5Rect1.Width, top5Rect1.Height);
            ingame.RenderOnScreen(top5Rect3, Best5GfxRect, baseUIColor);
            Rectangle top5Rect4 = new Rectangle(top5Rect1.X,
                                                top5Rect3.Bottom + top5Distance, top5Rect1.Width, top5Rect1.Height);
            ingame.RenderOnScreen(top5Rect4, Best5GfxRect, baseUIColor);
            Rectangle top5Rect5 = new Rectangle(top5Rect1.X,
                                                top5Rect4.Bottom + top5Distance, top5Rect1.Width, top5Rect1.Height);
            ingame.RenderOnScreen(top5Rect5, Best5GfxRect, baseUIColor);

            Rectangle tachoRect = BaseGame.CalcRectangle1600(
                10, 10, TachoGfxRect.Width, TachoGfxRect.Height);
            tachoRect.X = BaseGame.Width - tachoRect.Right;
            tachoRect.Y = BaseGame.Height - tachoRect.Bottom;
#endif

            // Rest can stay the same because we use the rectangles from now on
            ingame.RenderOnScreen(tachoRect, TachoGfxRect, baseUIColor);

            // Ok, now add the numbers, text and speed values
            TextureFontBigNumbers.WriteNumber(
                lapsRect.X + BaseGame.XToRes1600(15),
                lapsRect.Y + BaseGame.YToRes1200(12),
                lapNumber);

            // Current and best game times
            Color highlightColor = new Color(255, 185, 80);
            int   blockHeight    = BaseGame.YToRes1200(74);
            TextureFont.WriteGameTime(
                timesRect.X + BaseGame.XToRes1600(154),
                timesRect.Y + blockHeight / 2 - TextureFont.Height / 2,
                currentGameTime,
                highlightColor);
            TextureFont.WriteGameTime(
                timesRect.X + BaseGame.XToRes1600(154),
                timesRect.Y + timesRect.Height / 2 + blockHeight / 2 -
                TextureFont.Height / 2,
                bestLapTime,
                Color.White);

            // Track name
            TextureFont.WriteTextCentered(
                trackNameRect.X + trackNameRect.Width / 2,
                trackNameRect.Y + blockHeight / 2,
                trackName);

            // Top 5
            // Possible improvement: Show currentRank here (insert us)
            Color rankColor =
                bestLapTime == top5LapTimes[0] ?
                highlightColor : Color.White;
            TextureFont.WriteTextCentered(
                top5Rect1.X + BaseGame.XToRes(32) / 2,
                top5Rect1.Y + blockHeight / 2,
                "1.", rankColor, 1.0f);
            TextureFont.WriteGameTime(
                top5Rect1.X + BaseGame.XToRes(35 + 15),
                top5Rect1.Y + blockHeight / 2 - TextureFont.Height / 2,
                top5LapTimes[0], rankColor);

            rankColor =
                bestLapTime == top5LapTimes[1] ?
                highlightColor : Color.White;
            TextureFont.WriteTextCentered(
                top5Rect2.X + BaseGame.XToRes(32) / 2,
                top5Rect2.Y + blockHeight / 2,
                "2.", rankColor, 1.0f);
            TextureFont.WriteGameTime(
                top5Rect2.X + BaseGame.XToRes(35 + 15),
                top5Rect2.Y + blockHeight / 2 - TextureFont.Height / 2,
                top5LapTimes[1], rankColor);

            rankColor =
                bestLapTime == top5LapTimes[2] ?
                highlightColor : Color.White;
            TextureFont.WriteTextCentered(
                top5Rect3.X + BaseGame.XToRes(32) / 2,
                top5Rect3.Y + blockHeight / 2,
                "3.", rankColor, 1.0f);
            TextureFont.WriteGameTime(
                top5Rect3.X + BaseGame.XToRes(35 + 15),
                top5Rect3.Y + blockHeight / 2 - TextureFont.Height / 2,
                top5LapTimes[2], rankColor);

            rankColor =
                bestLapTime == top5LapTimes[3] ?
                highlightColor : Color.White;
            TextureFont.WriteTextCentered(
                top5Rect4.X + BaseGame.XToRes(32) / 2,
                top5Rect4.Y + blockHeight / 2,
                "4.", rankColor, 1.0f);
            TextureFont.WriteGameTime(
                top5Rect4.X + BaseGame.XToRes(35 + 15),
                top5Rect4.Y + blockHeight / 2 - TextureFont.Height / 2,
                top5LapTimes[3], rankColor);

            rankColor =
                bestLapTime == top5LapTimes[4] ?
                highlightColor : Color.White;
            TextureFont.WriteTextCentered(
                top5Rect5.X + BaseGame.XToRes(32) / 2,
                top5Rect5.Y + blockHeight / 2,
                "5.", rankColor, 1.0f);
            TextureFont.WriteGameTime(
                top5Rect5.X + BaseGame.XToRes(35 + 15),
                top5Rect5.Y + blockHeight / 2 - TextureFont.Height / 2,
                top5LapTimes[4], rankColor);

            // Acceleration
            Point tachoPoint = new Point(
                tachoRect.X +
                BaseGame.XToRes1600(194),
                tachoRect.Y +
                BaseGame.YToRes1200(194));
            //ingame.RenderOnScreenWithRotation(
            //    tachoPoint, TachoArrowGfxRect, -acceleration*2);
            if (acceleration < 0)
            {
                acceleration = 0;
            }
            if (acceleration > 1)
            {
                acceleration = 1;
            }
            float   rotation         = -2.33f + acceleration * 2.5f;
            int     tachoArrowWidth  = BaseGame.XToRes1600(TachoArrowGfxRect.Width);
            int     tachoArrowHeight = BaseGame.YToRes1200(TachoArrowGfxRect.Height);
            Vector2 rotationPoint    = new Vector2(
                TachoArrowGfxRect.Width / 2,
                TachoArrowGfxRect.Height - 13);
            ingame.RenderOnScreenWithRotation(
                new Rectangle(tachoPoint.X, tachoPoint.Y,
                              tachoArrowWidth, tachoArrowHeight),
                TachoArrowGfxRect,
                rotation, rotationPoint);

            // Speed in mph
            TextureFontBigNumbers.WriteNumber(
                tachoRect.X + BaseGame.XToRes1600(TachoMphGfxRect.X),
                tachoRect.Y + BaseGame.YToRes1200(TachoMphGfxRect.Y),
                TachoMphGfxRect.Height,
                (int)Math.Round(speed));

            // Gear
            TextureFontBigNumbers.WriteNumber(
                tachoRect.X + BaseGame.XToRes1600(TachoGearGfxRect.X),
                tachoRect.Y + BaseGame.YToRes1200(TachoGearGfxRect.Y),
                TachoGearGfxRect.Height,
                Math.Min(5, gear));
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Test textures
        /// </summary>
        //[Test]
        public static void TestTextures()
        {
            Texture testTexture = null;
            TestGame.Start("TestTextures",
                delegate
                {
                    //testTexture = new Texture("MouseCursor.dds");
                    testTexture = new Texture("Sun");
                },
                delegate
                {
                    testTexture.RenderOnScreen(
                        new Rectangle(100, 100, 256, 256),
                        testTexture.GfxRectangle,
                        Color.White, SpriteBlendMode.None);

                    // Use alpha blending
                    testTexture.RenderOnScreen(
                        new Rectangle(Input.MousePos.X, Input.MousePos.Y, 512, 512),
                        testTexture.GfxRectangle,
                        new Color(64, 64, 64, 64), SpriteBlendMode.Additive);
                });
        }
Ejemplo n.º 5
0
        /*not that easy without fixed function
        /// <summary>
        /// Select this texture as texture stage 0
        /// </summary>
        public virtual void Select()
        {
            if (xnaTexture != null)
                RCGame.device.sette.DirectXDevice.SetTexture(0, xnaTexture);
        } // Select()
         */

        #endregion Other

        #if DEBUG

        /*
        /// <summary>
        /// Test fullscreen texture
        /// </summary>
        //[Test]
        public static void TestFullscreenTextures()
        {
            Texture testTexture = null, testTexture2 = null;
            RaceGame.StartTest("TestFullscreenTextures",
                delegate
                {
                    testTexture = new Texture("MainMenu.dds");
                    testTexture2 = new Texture("MouseCursor.dds");
                },
                delegate
                {
                    // Fill background with crazy color
                    RaceGame.DirectXDevice.Clear(ClearFlags.Target,
                        Color.Aquamarine, 1, 0);

                    // Draw texture on top of it without any alpha!
                    RaceGame.DirectXDevice.RenderState.AlphaBlendEnable = false;
                    testTexture.RenderOnScreen(
                        GraphicForm.ResolutionRect,
                        new Rectangle(0, 0, 1024, 768));
                    testTexture2.RenderOnScreen(new Rectangle(0, 0,
                        testTexture2.Width, testTexture2.Height));
                });
        } // TestTextures()
         */
        /// <summary>
        /// Test rendering rotated texture
        /// </summary>
        //[Test]
        public static void TestRenderingRotatedTexture()
        {
            Texture testTexture = null;
            TestGame.Start("TestRenderingRotatedTexture",
                delegate
                {
                    testTexture = new Texture("landscape");
                },
                delegate
                {
                    testTexture.RenderOnScreen(
                        new Rectangle(0, 0, 100, 100),
                        new Rectangle(0, 0, 100, 100));

                    testTexture.RenderOnScreenWithRotation(
                        new Rectangle(100, 100, 150, 150),
                        new Rectangle(100, 100, 150, 150),
                        Input.MousePos.X / 100.0f,
                        new Vector2(50, 50));
                });
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Render game user interface
        /// </summary>
        /// <param name="currentGameTime">Current game time</param>
        /// <param name="bestLapTime">Best lap time</param>
        /// <param name="lapNumber">Lap number</param>
        /// <param name="speed">Speed</param>
        /// <param name="gear">Gear</param>
        /// <param name="trackName">Track name</param>
        /// <param name="top5LapTimes">Top 5 lap times</param>
        public void RenderGameUI(int currentGameTime, int bestLapTime,
                                 int lapNumber, float speed, int gear, float acceleration,
                                 string trackName, Dictionary <string, RemotePlayer> players)
        {
            Color baseUIColor = Color.White;//ColorHelper.HalfAlpha;

            // If game is over, set speed, gear and acceleration to 0
            if (RacingGameManager.Player.GameOver)
            {
                speed        = 0;
                gear         = 1;
                acceleration = 0;
            }

            // More distance to the screen borders on the Xbox 360 to fit better into
            // the save region. Calculate all rectangles for each platform,
            // then they will be used the same way on both platforms.
#if XBOX360
            // Draw all boxes and background stuff
            Rectangle lapsRect = BaseGame.CalcRectangle1600(
                60, 46, LapsGfxRect.Width, LapsGfxRect.Height);
            ingame.RenderOnScreen(lapsRect, LapsGfxRect, baseUIColor);

            Rectangle timesRect = BaseGame.CalcRectangle1600(
                60, 46, CurrentAndBestGfxRect.Width, CurrentAndBestGfxRect.Height);
            timesRect.Y = BaseGame.Height - timesRect.Bottom;
            ingame.RenderOnScreen(timesRect, CurrentAndBestGfxRect, baseUIColor);

            Rectangle trackNameRect = BaseGame.CalcRectangle1600(
                60, 46, TrackNameGfxRect.Width, TrackNameGfxRect.Height);
            trackNameRect.X = BaseGame.Width - trackNameRect.Right;
            ingame.RenderOnScreen(trackNameRect, TrackNameGfxRect, baseUIColor);
            Rectangle top5Rect1 = BaseGame.CalcRectangle1600(
                60, 4, Best5GfxRect.Width, Best5GfxRect.Height);
            top5Rect1.X = trackNameRect.X;
            int top5Distance = top5Rect1.Y;
            top5Rect1.Y += trackNameRect.Bottom;
            ingame.RenderOnScreen(top5Rect1, Best5GfxRect, baseUIColor);
            Rectangle top5Rect2 = new Rectangle(top5Rect1.X,
                                                top5Rect1.Bottom + top5Distance, top5Rect1.Width, top5Rect1.Height);
            ingame.RenderOnScreen(top5Rect2, Best5GfxRect, baseUIColor);
            Rectangle top5Rect3 = new Rectangle(top5Rect1.X,
                                                top5Rect2.Bottom + top5Distance, top5Rect1.Width, top5Rect1.Height);
            ingame.RenderOnScreen(top5Rect3, Best5GfxRect, baseUIColor);
            Rectangle top5Rect4 = new Rectangle(top5Rect1.X,
                                                top5Rect3.Bottom + top5Distance, top5Rect1.Width, top5Rect1.Height);
            ingame.RenderOnScreen(top5Rect4, Best5GfxRect, baseUIColor);
            Rectangle top5Rect5 = new Rectangle(top5Rect1.X,
                                                top5Rect4.Bottom + top5Distance, top5Rect1.Width, top5Rect1.Height);
            ingame.RenderOnScreen(top5Rect5, Best5GfxRect, baseUIColor);

            Rectangle tachoRect = BaseGame.CalcRectangle1600(
                60, 46, TachoGfxRect.Width, TachoGfxRect.Height);
            tachoRect.X = BaseGame.Width - tachoRect.Right;
            tachoRect.Y = BaseGame.Height - tachoRect.Bottom;
#else
            // Draw all boxes and background stuff
            Rectangle lapsRect = BaseGame.CalcRectangle1600(
                10, 10, LapsGfxRect.Width, LapsGfxRect.Height);
            ingame.RenderOnScreen(lapsRect, LapsGfxRect, baseUIColor);

            Rectangle timesRect = BaseGame.CalcRectangle1600(
                10, 10, CurrentAndBestGfxRect.Width, CurrentAndBestGfxRect.Height);
            timesRect.Y = BaseGame.Height - timesRect.Bottom;
            ingame.RenderOnScreen(timesRect, CurrentAndBestGfxRect, baseUIColor);

            Rectangle trackNameRect = BaseGame.CalcRectangle1600(
                10, 10, TrackNameGfxRect.Width, TrackNameGfxRect.Height);
            trackNameRect.X = BaseGame.Width - trackNameRect.Right;
            ingame.RenderOnScreen(trackNameRect, TrackNameGfxRect, baseUIColor);


            Rectangle tachoRect = BaseGame.CalcRectangle1600(
                10, 10, TachoGfxRect.Width, TachoGfxRect.Height);
            tachoRect.X = BaseGame.Width - tachoRect.Right;
            tachoRect.Y = BaseGame.Height - tachoRect.Bottom;
#endif

            // Rest can stay the same because we use the rectangles from now on
            ingame.RenderOnScreen(tachoRect, TachoGfxRect, baseUIColor);

            // Ok, now add the numbers, text and speed values
            TextureFontBigNumbers.WriteNumber(
                lapsRect.X + BaseGame.XToRes1600(15),
                lapsRect.Y + BaseGame.YToRes1200(12),
                lapNumber);

            // Current and best game times
            Color highlightColor = new Color(255, 185, 80);
            int   blockHeight    = BaseGame.YToRes1200(74);
            TextureFont.WriteGameTime(
                timesRect.X + BaseGame.XToRes1600(154),
                timesRect.Y + blockHeight / 2 - TextureFont.Height / 2,
                currentGameTime,
                highlightColor);
            TextureFont.WriteGameTime(
                timesRect.X + BaseGame.XToRes1600(154),
                timesRect.Y + timesRect.Height / 2 + blockHeight / 2 -
                TextureFont.Height / 2,
                bestLapTime,
                Color.White);

            // Track name
            TextureFont.WriteTextCentered(
                trackNameRect.X + trackNameRect.Width / 2,
                trackNameRect.Y + blockHeight / 2,
                trackName);

            Rectangle top5Rect1 = BaseGame.CalcRectangle1600(
                10, 4, Best5GfxRect.Width, Best5GfxRect.Height);
            top5Rect1.X = trackNameRect.X;
            int top5Distance = top5Rect1.Y;
            top5Rect1.Y += trackNameRect.Bottom;

            Rectangle top5Rect2 = new Rectangle(top5Rect1.X,
                                                top5Rect1.Bottom + top5Distance, top5Rect1.Width, top5Rect1.Height);

            Rectangle top5Rect3 = new Rectangle(top5Rect1.X,
                                                top5Rect2.Bottom + top5Distance, top5Rect1.Width, top5Rect1.Height);

            Rectangle top5Rect4 = new Rectangle(top5Rect1.X,
                                                top5Rect3.Bottom + top5Distance, top5Rect1.Width, top5Rect1.Height);

            Rectangle top5Rect5 = new Rectangle(top5Rect1.X,
                                                top5Rect4.Bottom + top5Distance, top5Rect1.Width, top5Rect1.Height);


            int         index = 0;
            RankEntry[] ents  = new RankEntry[players.Count + 1];
            foreach (var e in players)
            {
                ents[index].Progress = e.Value.CompletionProgress;
                ents[index].ID       = e.Value.ID;
                ents[index++].Name   = e.Value.Name;
            }
            ents[index].Progress = RacingGameManager.Player.GetCompletionProgress();
            ents[index].ID       = RacingGameManager.LocalUID;
            ents[index].Name     = RacingGameManager.LocalPlayerName;
            Array.Sort(ents, RankComparision);

            if (ents.Length > 0)
            {
                // Top 5

                ingame.RenderOnScreen(top5Rect1, Best5GfxRect, baseUIColor);
                Color rankColor =
                    ents[0].ID == RacingGameManager.LocalUID ?
                    highlightColor : Color.White;
                TextureFont.WriteTextCentered(
                    top5Rect1.X + BaseGame.XToRes(32) / 2,
                    top5Rect1.Y + blockHeight / 2,
                    "1.", rankColor, 1.0f);
                TextureFont.WriteText(
                    top5Rect1.X + BaseGame.XToRes(35 + 15),
                    top5Rect1.Y + blockHeight / 2 - TextureFont.Height / 2,
                    ents[0].Name, rankColor);

                if (ents.Length > 1)
                {
                    rankColor =
                        ents[1].ID == RacingGameManager.LocalUID ?
                        highlightColor : Color.White;
                    TextureFont.WriteTextCentered(
                        top5Rect2.X + BaseGame.XToRes(32) / 2,
                        top5Rect2.Y + blockHeight / 2,
                        "2.", rankColor, 1.0f);
                    TextureFont.WriteText(
                        top5Rect2.X + BaseGame.XToRes(35 + 15),
                        top5Rect2.Y + blockHeight / 2 - TextureFont.Height / 2,
                        ents[1].Name, rankColor);
                    ingame.RenderOnScreen(top5Rect2, Best5GfxRect, baseUIColor);

                    if (ents.Length > 2)
                    {
                        rankColor =
                            ents[2].ID == RacingGameManager.LocalUID ?
                            highlightColor : Color.White;
                        TextureFont.WriteTextCentered(
                            top5Rect3.X + BaseGame.XToRes(32) / 2,
                            top5Rect3.Y + blockHeight / 2,
                            "3.", rankColor, 1.0f);
                        TextureFont.WriteText(
                            top5Rect3.X + BaseGame.XToRes(35 + 15),
                            top5Rect3.Y + blockHeight / 2 - TextureFont.Height / 2,
                            ents[2].Name, rankColor);
                        ingame.RenderOnScreen(top5Rect3, Best5GfxRect, baseUIColor);

                        if (ents.Length > 3)
                        {
                            rankColor =
                                ents[3].ID == RacingGameManager.LocalUID ?
                                highlightColor : Color.White;
                            TextureFont.WriteTextCentered(
                                top5Rect4.X + BaseGame.XToRes(32) / 2,
                                top5Rect4.Y + blockHeight / 2,
                                "4.", rankColor, 1.0f);
                            TextureFont.WriteText(
                                top5Rect4.X + BaseGame.XToRes(35 + 15),
                                top5Rect4.Y + blockHeight / 2 - TextureFont.Height / 2,
                                ents[3].Name, rankColor);
                            ingame.RenderOnScreen(top5Rect4, Best5GfxRect, baseUIColor);

                            if (ents.Length > 4)
                            {
                                rankColor =
                                    ents[4].ID == RacingGameManager.LocalUID ?
                                    highlightColor : Color.White;
                                TextureFont.WriteTextCentered(
                                    top5Rect5.X + BaseGame.XToRes(32) / 2,
                                    top5Rect5.Y + blockHeight / 2,
                                    "5.", rankColor, 1.0f);
                                TextureFont.WriteText(
                                    top5Rect5.X + BaseGame.XToRes(35 + 15),
                                    top5Rect5.Y + blockHeight / 2 - TextureFont.Height / 2,
                                    ents[4].Name, rankColor);
                                ingame.RenderOnScreen(top5Rect5, Best5GfxRect, baseUIColor);
                            }
                        }
                    }
                }
            }

            Viewport vp = RacingGameManager.graphicsManager.GraphicsDevice.Viewport;
            var      rp = RacingGameManager.RemotePlayers;
            foreach (var e in rp)
            {
                Matrix  trans = e.Value.Transform;
                Vector3 pos   = trans.Translation + trans.Up * 2.8f;

                Vector3 screnPos = vp.Project(pos, BaseGame.ProjectionMatrix, BaseGame.ViewMatrix, Matrix.Identity);
                if (screnPos.Z > 0 && screnPos.Z < 0.985f)
                {
                    Vector2 size = nameFont.MeasureString(e.Value.Name);
                    screnPos.X -= size.X * 0.5f;
                    screnPos.Y -= size.Y * 0.5f;
                    TextureFont.WriteText((int)screnPos.X, (int)screnPos.Y, e.Value.Name);
                    //nameBatch.DrawString(nameFont, e.Value.Name, new Vector2(pos.X, pos.Y), Color.White);
                }
            }

            //// Acceleration
            //Point tachoPoint = new Point(
            //    tachoRect.X +
            //    BaseGame.XToRes1600(194),
            //    tachoRect.Y +
            //    BaseGame.YToRes1200(194));
            ////ingame.RenderOnScreenWithRotation(
            ////    tachoPoint, TachoArrowGfxRect, -acceleration*2);
            //if (acceleration < 0)
            //    acceleration = 0;
            //if (acceleration > 1)
            //    acceleration = 1;
            //float rotation = -2.33f + acceleration * 2.5f;
            //int tachoArrowWidth = BaseGame.XToRes1600(TachoArrowGfxRect.Width);
            //int tachoArrowHeight = BaseGame.YToRes1200(TachoArrowGfxRect.Height);
            //Vector2 rotationPoint = new Vector2(
            //    TachoArrowGfxRect.Width / 2,
            //    TachoArrowGfxRect.Height - 13);
            //ingame.RenderOnScreenWithRotation(
            //    new Rectangle(tachoPoint.X, tachoPoint.Y,
            //    tachoArrowWidth, tachoArrowHeight),
            //    TachoArrowGfxRect,
            //    rotation, rotationPoint);

            // Speed in mph
            TextureFontBigNumbers.WriteNumber(
                tachoRect.X + BaseGame.XToRes1600(TachoMphGfxRect.X),
                tachoRect.Y + BaseGame.YToRes1200(TachoMphGfxRect.Y),
                TachoMphGfxRect.Height,
                (int)Math.Round(speed * 0.8f));

            //// Gear
            //TextureFontBigNumbers.WriteNumber(
            //    tachoRect.X + BaseGame.XToRes1600(TachoGearGfxRect.X),
            //    tachoRect.Y + BaseGame.YToRes1200(TachoGearGfxRect.Y),
            //    TachoGearGfxRect.Height,
            //    Math.Min(5, gear));
        }