public static void ClearTiles(D2DMapEditor d2d, Map map, ref Tile[] tileLibrary, Panel pnlTileLibrary) { // clear all tiles in the tile library // delete all controls pnlTileLibrary.Controls.Clear(); pnlTileLibrary.Refresh(); if (tileLibrary != null) { Array.Clear(tileLibrary, 0, tileLibrary.Length); Array.Resize(ref tileLibrary, 0); } // initialized map foreach (Layer layer in map.Layers) { for (int x = 0; x < layer.Width; x++) { for (int y = 0; y < layer.Height; y++) { layer.LayerData[x, y] = -1; } } } d2d.ClearSelectedTile(); }
public static void DeleteSelectedTile(D2DMapEditor d2d, Map map, ref Tile[] tileLibrary, Panel pnlTileLibrary, int selectedTileID) { // remove selected tile from tile library if (tileLibrary != null) { // remove that tile int i = 0; for (i = selectedTileID; i < tileLibrary.Length - 1; i++) { tileLibrary[i].TileWidth = tileLibrary[i + 1].TileWidth; tileLibrary[i].TileHeight = tileLibrary[i + 1].TileHeight; tileLibrary[i].TilePath = tileLibrary[i + 1].TilePath; tileLibrary[i].TileWalkable = tileLibrary[i + 1].TileWalkable; tileLibrary[i].TilePictureBox = tileLibrary[i + 1].TilePictureBox; if (tileLibrary[i + 1].TileName == tileLibrary[i + 1].TileID.ToString()) { tileLibrary[i].TileName = tileLibrary[i].TileID.ToString(); } else { tileLibrary[i].TileName = tileLibrary[i + 1].TileName; } //tileLibrary[i].TileID = i; } Array.Clear(tileLibrary, i, 1); Array.Resize(ref tileLibrary, tileLibrary.Length - 1); } // update map foreach (Layer layer in map.Layers) { for (int x = 0; x < layer.Width; x++) { for (int y = 0; y < layer.Height; y++) { if (layer.LayerData[x, y] == selectedTileID) { layer.LayerData[x, y] = -1; } else if (layer.LayerData[x, y] > selectedTileID) { layer.LayerData[x, y] = layer.LayerData[x, y] - 1; } } } } RenderTiles(map, ref tileLibrary, pnlTileLibrary); d2d.RenderMap(); d2d.ClearSelectedTile(); }
public static void ClearTiles(D2DMapEditor d2d, Map map, ref Tile[] tileLibrary, ListView lvTileLibrary, ImageList ilTileImages) { // clear all tiles in the tile library // delete all controls lvTileLibrary.Items.Clear(); //ilTileImages.Images.Clear(); if (tileLibrary != null) { Array.Clear(tileLibrary, 0, tileLibrary.Length); Array.Resize(ref tileLibrary, 0); } // initialized map foreach (Layer layer in map.Layers) for (int x = 0; x < layer.Width; x++) for (int y = 0; y < layer.Height; y++) layer.LayerData[x, y] = -1; lvTileLibrary.Refresh(); d2d.ClearSelectedTile(); }
public static void DeleteSelectedTile(D2DMapEditor d2d, Map map, ref Tile[] tileLibrary, ListView lvTileLibrary, ImageList ilTileImages, int selectedTileID) { // remove selected tile from tile library if (tileLibrary != null) { // remove that tile int i = 0; for (i = selectedTileID; i < tileLibrary.Length - 1; i++) { tileLibrary[i].TileWidth = tileLibrary[i + 1].TileWidth; tileLibrary[i].TileHeight = tileLibrary[i + 1].TileHeight; tileLibrary[i].TilePath = tileLibrary[i + 1].TilePath; tileLibrary[i].TileWalkable = tileLibrary[i + 1].TileWalkable; tileLibrary[i].TilePictureBox = tileLibrary[i + 1].TilePictureBox; tileLibrary[i].TilePictureBox.Name = tileLibrary[i].TileName; //if (tileLibrary[i + 1].TileName == tileLibrary[i + 1].TileID.ToString()) // tileLibrary[i].TileName = tileLibrary[i].TileID.ToString(); //else // tileLibrary[i].TileName = tileLibrary[i + 1].TileName; //tileLibrary[i].TileID = i; } Array.Clear(tileLibrary, i, 1); Array.Resize(ref tileLibrary, tileLibrary.Length - 1); //ilTileImages.Images.RemoveAt(selectedTileID); lvTileLibrary.Items.RemoveAt(selectedTileID); } // update map foreach (Layer layer in map.Layers) { for (int x = 0; x < layer.Width; x++) { for (int y = 0; y < layer.Height; y++) { if (layer.LayerData[x, y] == selectedTileID) { layer.LayerData[x, y] = -1; } else if (layer.LayerData[x, y] > selectedTileID) { layer.LayerData[x, y] = layer.LayerData[x, y] - 1; } } } } //RenderTiles(map, ref tileLibrary, lvTileLibrary); lvTileLibrary.Refresh(); d2d.RenderMap(); d2d.ClearSelectedTile(); }