Пример #1
0
        public void Draw(Graphics g, int currentRoomX, int currentRoomY)
        {
            Point contentSize = new Point(rooms.GetLength(0) * mapTiles.FrameSize.X, rooms.GetLength(1) * mapTiles.FrameSize.Y);
            g.PushClipRectangle(new Rectangle(200 - mapPaper.Width / 2, 150 - mapPaper.Height / 2 - 16, mapPaper.Width + 2, mapPaper.Height + 2));
            g.Begin();
            g.Draw(mapPaper, new Point(2, 2), new Color(0, 0, 0, 50));
            g.Draw(mapPaper, Point.Zero, new Color(255, 255, 255, 220));

            g.PushClipRectangle(new Rectangle((mapPaper.Width - contentSize.X) / 2, (mapPaper.Height - contentSize.Y) / 2, contentSize.X, contentSize.Y));

            for (int y = 0; y < rooms.GetLength(1); y++)
            {
                for (int x = 0; x < rooms.GetLength(0); x++)
                {
                    if (rooms[x, y] >= 0)
                    {
                        mapTiles.Draw(g, new Point(x * mapTiles.FrameSize.X, y * mapTiles.FrameSize.Y), rooms[x, y], new Color(255, 255, 255, 128));
                    }
                }
            }

            mapTiles.Draw(g, new Point(currentRoomX * mapTiles.FrameSize.X, currentRoomY * mapTiles.FrameSize.Y), 17);
            mapTiles.Draw(g, new Point(treasureX * mapTiles.FrameSize.X, treasureY * mapTiles.FrameSize.Y), 19);

            g.PopClipRectangle();

            g.End();
            g.PopClipRectangle();
        }
Пример #2
0
        private void DrawWidgets(Graphics g, GameTime gameTime, Widget w)
        {
            if (!w.IsVisible)
            {
                return;
            }

            g.PushClipRectangle(w.Dimension);

            if (w.IsOpaque)
            {
                g.Begin(SpriteBlendMode.AlphaBlend, SpriteSortMode.Deferred, SaveStateMode.SaveState);
                w.Draw(g, gameTime);
                g.End();
            }

            foreach (Widget c in w.Children)
            {
                DrawWidgets(g, gameTime, c);
            }

            g.PopClipRectangle();
        }