Exemplo n.º 1
0
        void Init(byte pixelWidth)
        {
            tiles = new TileList();
            //pre-populate the list with the number of tiles we defined slots for
            byte x = 0;
            byte y = 0;

            for (byte i = 0; i < (Height * Width); i++)
            {
                var tile = new Tile();

                var pixel = pixels[x, y];
                var scale = 3f;

                pixel.Paint += (s, e) =>
                {
                    var panel = (CellPanel)s;

                    var ptile = GetTile(panel.X, panel.Y, false);

                    for (var ix = 0; ix < ptile.Width; ix++)
                    {
                        for (var iy = 0; iy < ptile.Height; iy++)
                        {
                            var brush = new SolidBrush(PaletteUtility.GetColour(ptile.Data[ix, iy]));

                            e.Graphics.FillRectangle(brush, (ix * scale), (iy * scale), scale, scale);
                        }
                    }

                    var index = (panel.Y * Width) + panel.X;
                    if ((byte)index == selectedIndex)
                    {
                        e.Graphics.DrawRectangle(Pens.Red, 1, 1, pixelWidth - 5, pixelWidth - 5);
                    }

                    e.Graphics.DrawString($"({panel.Y},{panel.X})", SystemFonts.DialogFont, Brushes.Gray, 0, 0, StringFormat.GenericDefault);
                };

                tiles.Add(tile);

                x++;
                if (x == Width)
                {
                    x = 0;
                    y++;
                }
            }
        }
Exemplo n.º 2
0
 public TileMapFactory(TileList list)
 {
     List = list;
 }