Пример #1
0
        public override void Render(BufferedGraphics graphics)
        {
            for (int y = 0; y < _map.Layout.GetLength(0); y++)
            {
                for (int x = _map.Layout.GetLength(1) - 1; x >= 0; x--)
                {
                    SpriteEnum    sprinteEnum = _map.Layout[y, x];
                    SpriteDetails sprite      = _spriteSheets.GetSprite(sprinteEnum);
                    if (sprite != null)
                    {
                        // This is the point where the sprite should be painted.
                        Point pointOnScreen = GraphicsHelper.ConvertMapCoordsToWindowCoords(x, y, _graphicsTracker.MapOffset);

                        // Calculate the anchor location of the sprite.

                        var anchor = new Point(sprite.Location.X + sprite.Location.Width / 2, sprite.Location.Y + sprite.Location.Height - 32);

                        int xx = anchor.X - sprite.Location.X;
                        int yy = anchor.Y - sprite.Location.Y;

                        Point realPoint = new Point(pointOnScreen.X - xx, pointOnScreen.Y - yy);

                        graphics.Graphics.DrawImage(sprite.Bitmap, realPoint);
                        graphics.Graphics.DrawString(y + "," + x, _fontsAndColors.MonospaceFontSmaller,
                                                     _fontsAndColors.BlackBrush, pointOnScreen);
                    }
                }
            }
        }
Пример #2
0
        private Point ActualLocationByMap(int mapX, int mapY)
        {
            Point mapLocation = GraphicsHelper.ConvertMapCoordsToWindowCoords(mapX, mapY, Point.Empty);

            return(new Point(mapLocation.X, mapLocation.Y - 34));
        }