private void panelMap_MouseClick(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Left) //摆放怪物 { if (viewStack1.SelectedIndex == 1 && listViewMonster.SelectedItems.Count > 0) { String[] data = listViewMonster.SelectedItems[0].Text.Split('.'); int monid = int.Parse(data[0]); OldDataPack pack = OldDataPackBook.GetPack("cfg_map_monster"); List <String> datas = new List <string>(); datas.Add((++pack.maxid).ToString()); datas.Add(selectMapId.ToString()); datas.Add(monid.ToString()); Point p = TilePixelConvertor.PixelToTile(e.X + baseOffside.X, e.Y + baseOffside.Y); datas.Add(p.X.ToString()); datas.Add(p.Y.ToString()); pack.AddPackData(pack.maxid, datas); this.installLiveMonster(); updateMap(); } else if (viewStack1.SelectedIndex == 2 && listViewPlant.SelectedItems.Count > 0) { String[] data = listViewPlant.SelectedItems[0].Text.Split('.'); int pid = int.Parse(data[0]); OldDataPack pack = OldDataPackBook.GetPack("cfg_map_plant"); List <String> datas = new List <string>(); datas.Add((++pack.maxid).ToString()); datas.Add(selectMapId.ToString()); datas.Add(pid.ToString()); Point p = TilePixelConvertor.PixelToTile(e.X + baseOffside.X, e.Y + baseOffside.Y); datas.Add(p.X.ToString()); datas.Add(p.Y.ToString()); pack.AddPackData(pack.maxid, datas); this.installLivePlant(); updateMap(); } } }
private void buttonAdd_Click(object sender, EventArgs e) { AddDataForm adf = new AddDataForm(); adf.Label1 = pack.comment[0] != "" ? pack.comment[0] : pack.header[0]; adf.ShowDialog(); if (adf.Result == System.Windows.Forms.DialogResult.OK) { if (!pack.data.ContainsKey(adf.Id)) { List <String> data = new List <string>(); data.Add(adf.Id.ToString()); bool doCopy = false; if (pack.data.ContainsKey(selectId) && adf.NeedCopy) { doCopy = true; } for (int i = 1; i < pack.datatype.Count; i++) { if (doCopy) { data.Add(pack.data[selectId][i]); } else { if (pack.datatype[i] == "char") { data.Add(""); } else { data.Add("0"); } } } pack.AddPackData(adf.Id, data); refreshList(adf.Id); } } }