Beispiel #1
0
        protected override void Draw(GameTime gameTime)
        {
            GraphicsDevice.Clear(currentWorld == null?Color.CornflowerBlue:currentWorld.getBgColor());
            spriteBatch.Begin(SpriteSortMode.BackToFront, normalBlendState, SamplerState.PointClamp, DepthStencilState.DepthRead, RasterizerState.CullNone);

            GraphicsDevice.SamplerStates[0] = SamplerState.PointClamp;

            string e = "";
            string t = "";

            if (currentWorld != null)
            {
                currentWorld.Draw(this, gameTime);
                e = "Entity Count: " + currentWorld.EntityList.Count;

                int hr = (int)(currentWorld.time / 1000);

                t = "Time: " + (hr > 12?hr - 12:(hr == 0?12:hr)) + ":" + formatToHave2Digits(((int)(((currentWorld.time % 1000.0) / 1000.0) * 60.0))) + " " + (hr >= 12 ? "PM" : "AM") + " (" + (int)currentWorld.time + ")";
            }

            Profiler.start("draw gui");
            if (inventory != null)
            {
                inventory.draw(this, gameTime);
            }
            Profiler.end("draw gui");

            if (debugEnabled)
            {
                string d  = "Draw Fps: " + drawFps.getFps() + " (ms/t:" + drawFps.getMpt() + ") " + percent(drawFps.getFps(), 60) + "%";
                string u  = "Update Fps: " + updateFps.getFps() + " (ms/t:" + updateFps.getMpt() + ") " + percent(updateFps.getFps(), 60) + "%";
                string l  = "Lighting Fps: " + currentWorld.lightingThreadFps.getFps() + " (ms/t:" + currentWorld.lightingThreadFps.getMpt() + ") ";
                string lq = "Liquid Fps:   " + currentWorld.liquidThreadFps.getFps() + " (ms/t:" + currentWorld.liquidThreadFps.getMpt() + ") ";
                string p  = "Rendering:\n  Gui: " + Profiler.get("draw gui") + "\n  Tile: " + Profiler.get("draw tiles") + "\n  Entity: " + Profiler.get("draw entities");
                p += "\n\nLighting: " + Profiler.get("lighting");
                string ti = "T: " + currentWorld.getTileIndex(inventory.mouseTileX, inventory.mouseTileY, World.TileDepth.tile) + "`" + currentWorld.getTileData(inventory.mouseTileX, inventory.mouseTileY, World.TileDepth.tile);
                ti += "  W: " + currentWorld.getTileIndex(inventory.mouseTileX, inventory.mouseTileY, World.TileDepth.wall) + "`" + currentWorld.getTileData(inventory.mouseTileX, inventory.mouseTileY, World.TileDepth.wall);
                string pp = "Position: " + currentWorld.player.position.X + ", " + currentWorld.player.position.Y;

                spriteBatch.DrawString(fontNormal, d + "\n" + u + "\n" + l + "\n" + lq + "\n" + e + "\n" + t + "\n" + p + "\n" + ti + "\n" + pp + "\n" + drawMessage + "\n" + updateMessage, new Vector2(140, 10), Color.White);
            }
            drawMessage = "";

            console.draw(this, gameTime);

            spriteBatch.End();
            base.Draw(gameTime);
            drawFps.update();
        }