// implements IMapTools PaintTiles to reflect a medium paint, public void PaintTiles(ref MapTile[] map, int width, int startPosition, PaletteTile CurrentTile) { map[startPosition].Picture.Image = null; map[startPosition].Picture.Image = CurrentTile.Picture.Image; map[startPosition].PalletteID = CurrentTile.UniqueID; if ((startPosition % width) != width - 1) { map[startPosition + 1].Picture.Image = null; map[startPosition + 1].Picture.Image = CurrentTile.Picture.Image; map[startPosition + 1].PalletteID = CurrentTile.UniqueID; } if ((startPosition % width) != 0) { map[startPosition - 1].Picture.Image = null; map[startPosition - 1].Picture.Image = CurrentTile.Picture.Image; map[startPosition - 1].PalletteID = CurrentTile.UniqueID; } if ((startPosition / width) != (map.Length / width) - 1) { map[startPosition + width].Picture.Image = null; map[startPosition + width].Picture.Image = CurrentTile.Picture.Image; map[startPosition + width].PalletteID = CurrentTile.UniqueID; } if ((startPosition / width) != 0) { map[startPosition - width].Picture.Image = null; map[startPosition - width].Picture.Image = CurrentTile.Picture.Image; map[startPosition - width].PalletteID = CurrentTile.UniqueID; } }
// Iplements paint tiles to flood the map passed in with the specific tile. public void PaintTiles(ref MapTile[] map, int width, int startPosition, PaletteTile CurrentTile) { for (int i = 0; i < map.Length; i++) { map[i].Picture.Image = null; map[i].Picture.Image = CurrentTile.Picture.Image; map[i].PalletteID = CurrentTile.UniqueID; } }
/* * public void RefreshMap() * { * foreach (var box in MapPanel.Controls) * { * tileFlowPanel.Controls.Clear(); * } * for (int ii = 0; ii < map.Length; ii++) * { * MapPanel.Controls.Add(map[ii].Picture); * } * * } */ // clears the palette and repopulates it with all current tiles. public void PopulatePalette() { foreach (var box in tileFlowPanel.Controls) { tileFlowPanel.Controls.Clear(); } for (int ii = 0; ii < paletteTiles.Count; ii++) { paletteTiles.Clear(); } for (int ii = 0; ii < sheets.Count; ii++) { for (int i = 0; i < sheets[ii].TilesHigh * sheets[ii].TilesWide; i++) { PaletteTile palette = new PaletteTile(); palette.UniqueID = paletteTiles.Count; palette.SpriteSheetID = sheets[ii].UniqueID; PictureBox box = new PictureBox(); Bitmap drawArea = new Bitmap(size, size); box.Size = new Size(size, size); box.SizeMode = PictureBoxSizeMode.Zoom; box.Image = drawArea; box.Enabled = true; //box.MouseDown += new MouseEventHandler(TileMouseDown); palette.Picture = box; Graphics g = Graphics.FromImage(drawArea); g.FillRectangle(Brushes.White, 0, 0, drawArea.Width, drawArea.Height); Rectangle dest = new Rectangle(0, 0, size, size); palette.XStartPosition = (i % sheets[ii].TilesWide) * (sheets[ii].GridWidth + sheets[ii].Spacing); palette.YStartPosition = ((int)i / sheets[ii].TilesWide) * (sheets[ii].GridHeight + sheets[ii].Spacing); palette.Height = sheets[ii].GridWidth; palette.Width = sheets[ii].GridHeight; Rectangle source = new Rectangle(palette.XStartPosition, palette.YStartPosition, palette.Width, palette.Height); g.DrawImage(sheets[ii].Image, dest, source, GraphicsUnit.Pixel); palette.Picture.Image = drawArea; palette.Picture.MouseDown += new MouseEventHandler(TileBlockClicked); g.Dispose(); tileFlowPanel.Controls.Add(palette.Picture); paletteTiles.Add(palette); } } }
// implements IMapTools PaintTiles to reflect a small paint, public void PaintTiles(ref MapTile[] map, int width, int startPosition, PaletteTile CurrentTile) { map[startPosition].Picture.Image = null; map[startPosition].Picture.Image = CurrentTile.Picture.Image; map[startPosition].PalletteID = CurrentTile.UniqueID; }