private void doFindOasis(object o) { lock (Level2Lock) { FindOasisOption to = o as FindOasisOption; int VillageID = to.VillageID; TD.Villages[VillageID].OasisInfo.Clear(); TD.Villages[VillageID].isOasisFoundComplete = false; int axis_x, axis_y, total_times; axis_x = to.axis_x; axis_y = to.axis_y; total_times = to.search_num; string data; data = FetchBlockMap(VillageID, axis_x, axis_y); OasisFoundLog("[" + 1 + " / " + 1 + "] 搜索以(" + axis_x + "|" + axis_y + ")为中心的地图块"); for (int i = 1; i <= total_times; i++) { OasisFoundLog("正在进行第" + i + "重扫描:"); for (int j = 0; j < i; j++) { if (i % 2 == 1) { axis_y = CalcAxisTran(axis_y, 9); OasisFoundLog("[" + (j + 1) + " / " + (2 * i) + "] 搜索以(" + axis_x + "|" + axis_y + ")为中心的地图块"); data = FetchBlockMap(VillageID, axis_x, axis_y); } else { axis_y = CalcAxisTran(axis_y, -9); OasisFoundLog("[" + (j + 1) + " / " + (2 * i) + "] 搜索以(" + axis_x + "|" + axis_y + ")为中心的地图块"); data = FetchBlockMap(VillageID, axis_x, axis_y); } } for (int j = 0; j < i; j++) { if (i % 2 == 1) { axis_x = CalcAxisTran(axis_x, 11); OasisFoundLog("[" + (i + j + 1) + " / " + (2 * i) + "] 搜索以(" + axis_x + "|" + axis_y + ")为中心的地图块"); data = FetchBlockMap(VillageID, axis_x, axis_y); } else { axis_x = CalcAxisTran(axis_x, -11); OasisFoundLog("[" + (i + j + 1) + " / " + (2 * i) + "] 搜索以(" + axis_x + "|" + axis_y + ")为中心的地图块"); data = FetchBlockMap(VillageID, axis_x, axis_y); } } } int max_cnt = TD.Villages[VillageID].OasisInfo.Count; OasisFoundLog("总共扫描到" + max_cnt + "个15田。"); TD.Villages[VillageID].isOasisFoundComplete = true; int cnt = 0; foreach (var oas in TD.Villages[VillageID].OasisInfo) { cnt++; TOasisInfo oasis = oas as TOasisInfo; OasisFoundLog("[" + cnt + " / " + max_cnt + "] 搜索以(" + oasis.axis_x + "|" + oasis.axis_y + ")为中心的地图块"); data = FetchBlockMap(VillageID, oasis.axis_x, oasis.axis_y); oasis.addon = GetOasisAddon(data, oasis.axis_x, oasis.axis_y); } OasisFoundLog("打印搜索结果。"); StatusUpdate(this, new StatusChanged() { ChangedData = ChangedType.OasisFound, VillageID = VillageID }); } }
private void NewParseOasis(int VillageID, string data) { var CV = TD.Villages[VillageID]; if (CV.isOasisFoundComplete) return; Match m = Regex.Match(data, "\"error\":false,\"errorMsg\":null,\"data\":{\"tiles\":" + "\\[(.*?\\])}}"); if (!m.Success) return; MatchCollection mc_cell; mc_cell = Regex.Matches(m.Groups[1].Value, "{(.*?)}[,\\]]"); if(mc_cell.Count != 99) { DebugLog("��������ֻ����" + mc_cell.Count + "�����ݡ�", DebugLevel.E); return; } string cell, cell_type, sub_type; foreach (Match pm_cell in mc_cell) { cell = pm_cell.Groups[1].Value; /* {"x":"392","y":"351","c":"{k.vt} {k.f6}","t":" <span class=\"coordinates coordinatesWithText\"> <span class=\"coordinateX\">(392<\/span> <span class=\"coordinatePipe\">|<\/span> <span class=\"coordinateY\">351)<\/span> <\/span>"} */ m = Regex.Match(cell, "\"x\":\"(\\-?\\d+)\",\"y\":\"(\\-?\\d+)\"," + "\"c\":\"{([^}]*?)}\\s{([^}]*?)}\",\"t\":[^\\)]*?\\)<\\\\/span><\\\\/span>"); if (!m.Success) continue; cell_type = m.Groups[3].Value; sub_type = m.Groups[4].Value; // ������15�� if (cell_type == "k.vt" && sub_type == "k.f6") { TOasisInfo os_info = new TOasisInfo { axis_x = Convert.ToInt32(m.Groups[1].Value), axis_y = Convert.ToInt32(m.Groups[2].Value), type = sub_type, addon = 0 }; CV.OasisInfo.Add(os_info); } } }