private void button1_Click(object sender, EventArgs e) { // 解析攻击目标的坐标 if (this.txtX.Text == "" && this.txtY.Text == "" && this.textCoord.Text == "") return; else if(this.txtX.Text != "" || this.txtY.Text != "") { // 单目标情况 int x = 0, y = 0; Int32.TryParse(this.txtX.Text, out x); Int32.TryParse(this.txtY.Text, out y); var aTargets = new TPoint(x, y); iTargets.Add(aTargets); } else { // 多目标情况,格式:"xxx|yyy,xxx|yyy" if (!this.textCoord.Text.Contains(",")) return; string[] multipletargets = this.textCoord.Text.Split(','); for (int i = 0; i < multipletargets.Length; i++) { if (!multipletargets[i].Contains("|")) continue; string[] id = multipletargets[i].Split('|'); int x1 = 0, y1 = 0; Int32.TryParse(id[0], out x1); Int32.TryParse(id[1], out y1); TPoint tid = new TPoint(x1, y1); if (!tid.IsEmpty) iTargets.Add(tid); } } // 检查部队设置的数量是否超过现有的数量 for (int i = 0; i < 11; i++) { int totalattack = Convert.ToInt32(this.numericUpDown1.Value) * iTargets.Count; int[] totalraidtroops = new int[11]; int totaltroops = 0; int[] raidtroops = new int[11]; for (int j = 0; j < 5; j++) { int wv = Convert.ToInt32(Waves[j].Value); raidtroops[i] = Convert.ToInt32(Nums[j, i].Value); totaltroops = totaltroops + (raidtroops[i] * wv); } totalraidtroops[i] = totaltroops; if (totalraidtroops[i] * totalattack > Troops[i]) { var Nt = MessageBox.Show("No Enough Troop"); return; } } for (int j = 0; j < 5; j++) { int wv = Convert.ToInt32(Waves[j].Value); int[] raidtroops = new int[11]; int totaltroops = 0; for (int i = 0; i < 11; i++) { raidtroops[i] = Convert.ToInt32(Nums[j, i].Value); totaltroops = totaltroops + raidtroops[i]; } if (wv != 0 && totaltroops != 0) { TTInfo mTargets = new TTInfo { Troops = raidtroops }; nWaves.Add(wv); nTargets.Add(mTargets); } } if (nWaves.Count == 0 || nTargets.Count == 0 || iTargets.Count == 0) { if (!this.checkBox2.Checked) return; } Return = new AttackQueue { Raidtype = this.checkBox2.Checked ? 1 : this.comboBox3.SelectedIndex + 2, Targets = iTargets, wTroops = nTargets, wWaves = nWaves, VillageID = VillageID, kata = this.comboBox1.SelectedIndex, kata2 = this.comboBox2.SelectedIndex, Settlers = this.checkBox2.Checked, MinimumInterval = minimumInterval, NextExec = actionAt, }; }
private void buttonOK_Click(object sender, EventArgs e) { if (this.txtX.Text == "" && this.txtY.Text == "" && this.textCoord.Text == "") return; else if(this.textCoord.Text != "") { string multicoord = this.textCoord.Text.Replace(" ","").Replace("(","").Replace(")",""); string[] multipletargets = multicoord.Split(','); for (int i = 0; i < multipletargets.Length; i++) { if (!multipletargets[i].Contains("|")) continue; string[] id = multipletargets[i].Split('|'); int x1 = 0, y1 = 0; Int32.TryParse(id[0], out x1); Int32.TryParse(id[1], out y1); TPoint tid = new TPoint(x1, y1); if (!tid.IsEmpty) iTargets.Add(tid); } } else if(this.txtX.Text != "" || this.txtY.Text != "") { int x = 0, y = 0; Int32.TryParse(this.txtX.Text, out x); Int32.TryParse(this.txtY.Text, out y); var aTargets = new TPoint(x, y); if (!aTargets.IsEmpty) iTargets.Add(aTargets); } else { UpCall.DebugLog("No Attack Target!", DebugLevel.W); return; } if (iTargets == null || iTargets.Count == 0) { UpCall.DebugLog("Attack Coord is Error!", DebugLevel.W); return; } for (int i = 0; i < 11; i++) { int totalattack = Convert.ToInt32(this.numericUpDown1.Value) * iTargets.Count; int[] totalraidtroops = new int[11]; int totaltroops = 0; int[] raidtroops = new int[11]; for (int j = 0; j < 5; j++) { int wv = Convert.ToInt32(Waves[j].Value); raidtroops[i] = Convert.ToInt32(Nums[j, i].Value); totaltroops = totaltroops + (raidtroops[i] * wv); } totalraidtroops[i] = totaltroops; if ((totalraidtroops[i] * totalattack) > Troops[i]) { var Nt = MessageBox.Show("没有足够的军队"); return; } } for (int j = 0; j < 5; j++) { int wv = Convert.ToInt32(Waves[j].Value); int[] raidtroops = new int[11]; int totaltroops = 0; for (int i = 0; i < 11; i++) { raidtroops[i] = Convert.ToInt32(Nums[j, i].Value); totaltroops = totaltroops + raidtroops[i]; } if (wv != 0 && totaltroops != 0) { TTInfo mTargets = new TTInfo { Troops = raidtroops }; nWaves.Add(wv); nTargets.Add(mTargets); } } if (nWaves.Count == 0 || nTargets.Count == 0 || iTargets.Count == 0) { if (!this.checkBox2.Checked) return; } Return = new AttackQueue { Raidtype = this.checkBox2.Checked ? 1 : this.comboBox3.SelectedIndex + 2, Targets = iTargets, wTroops = nTargets, wWaves = nWaves, VillageID = VillageID, // MaxCount = Convert.ToInt32(this.numericUpDown1.Value), kata = this.comboBox1.SelectedIndex, kata2 = this.comboBox2.SelectedIndex, Settlers = this.checkBox2.Checked, MinimumInterval = minimumInterval, StartAt = actionAt, }; }