public void add_tile_set(Tileset tileset) { try { if (tileset == null) return; ProjectTileSet tmp = new ProjectTileSet(); tmp.tileset_name = tileset.Name; tmp.buffer = tileset.buffer; tmp.tileset_code = tileset.tileset_code; tmp.tiles = new ProjectTiles[tileset.setor.Count]; int i = 0; foreach (string key in tileset.setor.Keys) { ProjectTiles tmp_tiles = new ProjectTiles(); if (tileset.walk_region.ContainsKey(key)) { List<bool> walk_list = tileset.walk_region[key]; tmp_tiles.tileset_walk = new bool[walk_list.Count]; for (int j = 0; j < walk_list.Count; j++) { tmp_tiles.tileset_walk[j] = walk_list[j]; } } if (tileset.setor.ContainsKey(key)) { Setor sector = tileset.setor[key]; tmp_tiles.tileset_setor = new int[4]; tmp_tiles.tileset_setor[0] = sector.map_width; tmp_tiles.tileset_setor[1] = sector.map_height; tmp_tiles.tileset_setor[2] = sector.tile_width; tmp_tiles.tileset_setor[3] = sector.tile_height; } if (tileset.tile_image.ContainsKey(key)) { Dictionary<string, Image> list = tileset.tile_image[key]; tmp_tiles.tileset_names = new string[list.Count]; tmp_tiles.tileset_images = new List<byte[]>(); int j = 0; foreach (string names in list.Keys) { tmp_tiles.tileset_names[j] = names; Image crop_image = new Bitmap(list[names]); using (MemoryStream stream = new MemoryStream()) { crop_image.Save(stream, System.Drawing.Imaging.ImageFormat.Png); byte[] buffer = stream.ToArray(); tmp_tiles.tileset_images.Add(buffer); } j++; } } tmp.tiles[i] = tmp_tiles; i++; } tilesets.Add(tmp); } catch (Exception ex) { string error = ex.Message; } }
public void add_tile_set(Tileset tileset) { try { if (tileset == null) { return; } ProjectTileSet tmp = new ProjectTileSet(); tmp.tileset_name = tileset.Name; tmp.buffer = tileset.buffer; tmp.tileset_code = tileset.tileset_code; tmp.tiles = new ProjectTiles[tileset.setor.Count]; int i = 0; foreach (string key in tileset.setor.Keys) { ProjectTiles tmp_tiles = new ProjectTiles(); if (tileset.walk_region.ContainsKey(key)) { List <bool> walk_list = tileset.walk_region[key]; tmp_tiles.tileset_walk = new bool[walk_list.Count]; for (int j = 0; j < walk_list.Count; j++) { tmp_tiles.tileset_walk[j] = walk_list[j]; } } if (tileset.setor.ContainsKey(key)) { Setor sector = tileset.setor[key]; tmp_tiles.tileset_setor = new int[4]; tmp_tiles.tileset_setor[0] = sector.map_width; tmp_tiles.tileset_setor[1] = sector.map_height; tmp_tiles.tileset_setor[2] = sector.tile_width; tmp_tiles.tileset_setor[3] = sector.tile_height; } if (tileset.tile_image.ContainsKey(key)) { Dictionary <string, Image> list = tileset.tile_image[key]; tmp_tiles.tileset_names = new string[list.Count]; tmp_tiles.tileset_images = new List <byte[]>(); int j = 0; foreach (string names in list.Keys) { tmp_tiles.tileset_names[j] = names; Image crop_image = new Bitmap(list[names]); using (MemoryStream stream = new MemoryStream()) { crop_image.Save(stream, System.Drawing.Imaging.ImageFormat.Png); byte[] buffer = stream.ToArray(); tmp_tiles.tileset_images.Add(buffer); } j++; } } tmp.tiles[i] = tmp_tiles; i++; } tilesets.Add(tmp); } catch (Exception ex) { string error = ex.Message; } }