Example #1
0
        public void DrawRoom(Graphics2D g, Vector2F position)
        {
            g.Translate(position);

            // Draw background (in the color of the HUD.
            Rectangle2I viewRect = new Rectangle2I(0, 0, GameSettings.VIEW_WIDTH, GameSettings.VIEW_HEIGHT);

            g.DrawSprite(GameData.SPR_HUD_BACKGROUND, GameData.VARIANT_DARK, viewRect);

            Vector2F viewTranslation = -GMath.Round(viewControl.ViewPosition);

            g.Translate(viewTranslation);

            // Draw tiles.
            roomGraphics.Clear();
            tileManager.DrawTiles(roomGraphics);
            roomGraphics.DrawAll(g);

            // DEBUG: Draw debug information over tiles.
            GameDebug.DrawRoomTiles(g, this);

            // Draw entities in reverse order (because newer entities are drawn below older ones).
            roomGraphics.Clear();
            for (int i = entities.Count - 1; i >= 0; i--)
            {
                entities[i].Draw(roomGraphics);
            }
            roomGraphics.SortDepthLayer(DepthLayer.PlayerAndNPCs);             // Sort dynamic depth layers.
            roomGraphics.DrawAll(g);

            // Draw event tiles in reverse order.
            for (int i = eventTiles.Count - 1; i >= 0; i--)
            {
                eventTiles[i].Draw(g);
            }

            // DEBUG: Draw debug information.
            GameDebug.DrawRoom(g, this);

            g.Translate(-(position + viewTranslation));
        }