private void doFindAnimals(object o) { lock (Level2Lock) { FindAnimalsOption option = o as FindAnimalsOption; int VillageID = option.VillageID; int Range = option.Range; int axis_x = option.AxisX; int axis_y = option.AxisY; List <int> lstIncl = option.lstIncl; List <int> lstExcl = option.lstExcl; AnimalsFoundLog("开始以村子【" + TD.Villages[VillageID].Name + "(" + axis_x + "|" + axis_y + ")】为中心,在" + Range + "范围内搜索野兽。"); AnimalsFoundLog("[" + 1 + " / " + 1 + "] 搜索以(" + axis_x + "|" + axis_y + ")为中心的地图块"); string data = FetchBlockMap(VillageID, axis_x, axis_y); if (data != null) { ParseAnimalAreas(VillageID, data, lstIncl, lstExcl); } for (int i = 1; i <= Range; i++) { AnimalsFoundLog("正在进行第" + i + "重扫描:"); for (int j = 0; j < i; j++) { if (i % 2 == 1) { axis_y = CalcAxisTran(axis_y, 9); AnimalsFoundLog("[" + (j + 1) + " / " + (2 * i) + "] 搜索以(" + axis_x + "|" + axis_y + ")为中心的地图块"); data = FetchBlockMap(VillageID, axis_x, axis_y); } else { axis_y = CalcAxisTran(axis_y, -9); AnimalsFoundLog("[" + (j + 1) + " / " + (2 * i) + "] 搜索以(" + axis_x + "|" + axis_y + ")为中心的地图块"); data = FetchBlockMap(VillageID, axis_x, axis_y); } if (data != null) { ParseAnimalAreas(VillageID, data, lstIncl, lstExcl); } } for (int j = 0; j < i; j++) { if (i % 2 == 1) { axis_x = CalcAxisTran(axis_x, 11); AnimalsFoundLog("[" + (i + j + 1) + " / " + (2 * i) + "] 搜索以(" + axis_x + "|" + axis_y + ")为中心的地图块"); data = FetchBlockMap(VillageID, axis_x, axis_y); } else { axis_x = CalcAxisTran(axis_x, -11); AnimalsFoundLog("[" + (i + j + 1) + " / " + (2 * i) + "] 搜索以(" + axis_x + "|" + axis_y + ")为中心的地图块"); data = FetchBlockMap(VillageID, axis_x, axis_y); } if (data != null) { ParseAnimalAreas(VillageID, data, lstIncl, lstExcl); } } } } }
public void FindAnimals(FindAnimalsOption option) { ThrdFindAnimals = new Thread(new ParameterizedThreadStart(doFindAnimals)); ThrdFindAnimals.Name = "FindAnimals"; ThrdFindAnimals.Start(option); }
void Button1Click(object sender, EventArgs e) { if (bIsInSearching) return; int range, axis_x, axis_y; range = axis_x = axis_y = 0; try { range = Convert.ToInt32(this.numericUpDown1.Value); axis_x = Convert.ToInt32(this.numericUpDown2.Value); axis_y = Convert.ToInt32(this.numericUpDown3.Value); } catch { return; } FindAnimalsOption option = new FindAnimalsOption() { Range = range, AxisX = axis_x, AxisY = axis_y, }; for (int i = 0; i < CBAnimalsInclude.Length; i++) { if (CBAnimalsInclude[i].Checked) { option.lstIncl.Add(i + 1 + 30); } } for (int i = 0; i < CBAnimalsExclude.Length; i++) { if (CBAnimalsExclude[i].Checked) { option.lstExcl.Add(i + 1 + 30); } } this.listView1.Items.Clear(); UpCall.FindAnimalsClick(option); }
// 找野兽 public void FindAnimals(FindAnimalsOption option) { option.VillageID = ID; UpCall.FindAnimals(option); }
public void FindAnimalsClick(FindAnimalsOption option) { if (!TravianData.Villages.ContainsKey(SelectVillage)) return; AnimalsInfoList.Clear(); TravianData.Villages[SelectVillage].FindAnimals(option); }