// 타일 이미지를 불러와 맵 정보에 추가한다 public void LoadTile(string path, bool isWalkable = true) { int id = mapData.tileData.Count - 1; mapData.tileData[id] = new Tuple <string, bool>() { first = path, second = isWalkable }; TilePaletteItem item = new TilePaletteItem(); item.Setup(this, id); }
// 이름대로 private void 열기ToolStripMenuItem_Click(object sender, EventArgs e) { OpenFileDialog ofd = new OpenFileDialog(); ofd.Filter = "맵 파일|*.gze1206.map"; ofd.InitialDirectory = "../Resources"; if (ofd.ShowDialog() == DialogResult.OK) { mapData = FileManager.Get.ReadFile <MapData>(ofd.FileName); tbMapWidth.Text = mapData.width.ToString(); tbMapHeight.Text = mapData.height.ToString(); TilePaletteItem item; foreach (var i in mapData.tileData.Keys) { item = new TilePaletteItem(); item.Setup(this, i); } foreach (var iter in tileList) { splitContainer1.Panel2.Controls.Remove(iter.picture); } tileList.Clear(); Tile tile; for (int i = 0; i < mapData.height; i++) { for (int j = 0; j < mapData.width; j++) { tile = new Tile(); tile.pos = new Point(64 * j, 64 * i); tile.index = new Point(j, i); tile.Setup(this); } } } }
public MapEditor() { InitializeComponent(); tbMapWidth.LostFocus += OnLostFocus; tbMapHeight.LostFocus += OnLostFocus; appStartPath = new Uri(Path.Combine(Application.StartupPath, "./")); mapData = new MapData(); mapData.tiles.Resize(new Size(10, 10)); tbMapWidth.Text = mapData.width.ToString(); tbMapHeight.Text = mapData.height.ToString(); TilePaletteItem item; foreach (var i in mapData.tileData.Keys) { item = new TilePaletteItem(); item.Setup(this, i); } Tile tile; for (int i = 0; i < mapData.height; i++) { for (int j = 0; j < mapData.width; j++) { tile = new Tile(); tile.pos = new Point(64 * j, 64 * i); tile.index = new Point(j, i); tile.Setup(this); } } }