private Vector2 DrawText(SamplerState samplerState, Vector2 p)
 {
     p = DrawHeading(samplerState.ToString(), p, .6f);
     p = DrawText(samplerState, p, new Vector2(.2f, .2f));
     p = DrawText(samplerState, p, Vector2.One);
     return(DrawText(samplerState, p, new Vector2(1.1f, 1.1f)));
 }
        protected override void Draw(GameTime gameTime)
        {
            GraphicsDevice.Viewport = new Viewport
            {
                X        = 0,
                Y        = 0,
                Width    = WINDOW_WIDTH,
                Height   = WINDOW_HEIGHT,
                MinDepth = 0,
                MaxDepth = 1
            };
            GraphicsDevice.Clear(Color.Black);

            TextCounter = 0;
            float textHeight = DefaultSpriteFont.MeasureString("d").Y;

            Rectangle pxDestRectangle = new Rectangle(0, 0, WINDOW_WIDTH, WINDOW_HEIGHT);

            // Draw the World View Port, Centered on the CurrentPlayer Actor.
            ViewPortInfo viewPort = Engine.DrawWorldViewPort(
                SpriteBatch,
                Engine.GetEntity("Player").Pos,
                Zoom,
                pxDestRectangle,
                Color.White,
                CurrentSampler,
                DefaultSpriteFont);

            // DRAW DEBUGGING INFORMATION
            SpriteBatch.Begin();
            {
                if (showDebugInfo)
                {
                    // DRAW THE LIGHT MAP OUTPUT TO THE SCREEN FOR DEBUGGING
                    if (LightShader.Enabled)
                    {
                        int lightMapHeight = 100;
                        int lightMapWidth  = (int)Math.Ceiling(100 * ((float)LightShader.LightMap.Width / LightShader.LightMap.Height));

                        SpriteBatch.Draw(
                            LightShader.LightMap,
                            new Rectangle(
                                WINDOW_WIDTH - lightMapWidth, 0,
                                lightMapWidth, lightMapHeight
                                ),
                            Color.White
                            );
                    }

                    double fps      = 1000 / gameTime.ElapsedGameTime.TotalMilliseconds;
                    Color  fpsColor = (Math.Ceiling(fps) < 60) ? Color.Red : Color.White;

                    float TX = CurrentPlayer.Pos.X / Engine.Map.TileWidth;
                    float TY = CurrentPlayer.Pos.Y / Engine.Map.TileHeight;

                    this.IsMouseVisible = true;
                    MouseState mouseState = Mouse.GetState();

                    Vector2 worldCoord = viewPort.GetWorldCoordinates(new Point(mouseState.X, mouseState.Y));
                    Vector2 tileCoord  = worldCoord / (new Vector2(Engine.Map.TileWidth, Engine.Map.TileHeight));;
                    tileCoord.X = (int)Math.Floor(tileCoord.X);
                    tileCoord.Y = (int)Math.Floor(tileCoord.Y);

                    SpriteBatch.DrawString(DefaultSpriteFont, CurrentPlayer.Pos.ToString(), GeneratePos(textHeight), Color.White);
                    SpriteBatch.DrawString(DefaultSpriteFont, TX.ToString("0.0") + "," + TY.ToString("0.0"), GeneratePos(textHeight), Color.White);
                    SpriteBatch.DrawString(DefaultSpriteFont, "Coins=" + CurrentPlayer.Coins, GeneratePos(textHeight), Color.White);
                    SpriteBatch.DrawString(DefaultSpriteFont, "HP=" + CurrentPlayer.HP, GeneratePos(textHeight), Color.White);
                    SpriteBatch.DrawString(DefaultSpriteFont, fps.ToString("0.0 FPS"), GeneratePos(textHeight), fpsColor);
                    SpriteBatch.DrawString(DefaultSpriteFont, "Resolution=" + Engine.PixelWidth + "x" + Engine.PixelHeight, GeneratePos(textHeight), Color.White);
                    SpriteBatch.DrawString(DefaultSpriteFont, "MapSize=" + Engine.Map.txWidth + "x" + Engine.Map.txHeight, GeneratePos(textHeight), Color.White);
                    SpriteBatch.DrawString(DefaultSpriteFont, "Sampler=" + CurrentSampler.ToString(), GeneratePos(textHeight), Color.White);
                    SpriteBatch.DrawString(DefaultSpriteFont, "Entities On Screen = " + Engine.EntitiesOnScreen.Count, GeneratePos(textHeight), Color.White);
                    SpriteBatch.DrawString(DefaultSpriteFont, "Total Entities = " + Engine.Entities.Count, GeneratePos(textHeight), Color.White);
                    SpriteBatch.DrawString(DefaultSpriteFont, "Actual Zoom = " + viewPort.ActualZoom, GeneratePos(textHeight), Color.White);
                    SpriteBatch.DrawString(DefaultSpriteFont, "Mouse World Coordinates = " + worldCoord, GeneratePos(textHeight), Color.White);
                    SpriteBatch.DrawString(DefaultSpriteFont, "Mouse Tile Coordinates = " + tileCoord, GeneratePos(textHeight), Color.White);
                }

                if (showDiagnostics)
                {
                    StringBuilder builder = new StringBuilder();
                    builder.AppendLine(Engine.OverallPerformance.Description);
                    builder.AppendLine(Engine.OverallPerformance.ShowAll(false));

                    builder.AppendLine(Engine.EntityUpdatePerformance.Description);
                    builder.AppendLine(Engine.EntityUpdatePerformance.ShowTop(5));

                    string textOutput = builder.ToString();
                    SpriteBatch.DrawString(DefaultSpriteFont, textOutput, new Vector2(0, WINDOW_HEIGHT - DefaultSpriteFont.MeasureString(textOutput).Y), Color.White);
                }
            }
            SpriteBatch.End();

            base.Draw(gameTime);
        }