示例#1
0
 private void SetTileSet(TilesetData set)
 {
     (CurrentTileset = set).LoadImages(WorkingDirectory);
     pnlPossibleTiles.Controls.Clear();
     for (int i = 0; i < set.Tiles.Count; i++)
     {
         PictureBox tileButton = new PictureBox();
         tileButton.Width  = 16;
         tileButton.Height = 16;
         tileButton.Left   = 16 * (i % 6);
         tileButton.Top    = 16 * (i / 6);
         set.Tiles[i].Image.CurrentPalette = set.Tiles[i].Palette == 1 ? set.Palette1 : set.Palette2;
         tileButton.Image  = set.Tiles[i].Image.Target;
         tileButton.Tag    = i;
         tileButton.Click += btnTileButton_Click;
         tileButton.ResizeByZoom();
         pnlPossibleTiles.Controls.Add(tileButton);
         tileButton.FixZoom();
     }
     if (Tiles != null)
     {
         Render();
         UpdatePreview();
     }
 }
示例#2
0
        private void RenderPictureboxFromTile(PictureBox pictureBox, MapTile tile)
        {
            if (tile.TileID >= CurrentTileset.Tiles.Count)
            {
                tile.TileID = CurrentTileset.Tiles.Count - 1;
            }
            pictureBox.BackgroundImage = CurrentTileset.Tiles[tile.TileID].Image.Target;
            Point pos       = new Point(pictureBox.Left / TILE_SIZE, pictureBox.Top / TILE_SIZE);
            int   unitIndex = Units.FindIndex(a => a.Pos == pos);

            if (unitIndex >= 0)
            {
                pictureBox.Image = Units[unitIndex].image ?? GetUnitImage(Units[unitIndex]);
            }
            else
            {
                pictureBox.Image = null;
            }
            pictureBox.FixZoom();
        }