//遍历并获取当前连通区域内的起点和终点数量 private void Count_s_e(ref int[] s_count, ref int s_num, ref int e_num, bool last_is_start) { bool is_start = false; if (type == GridType.SEED) { if (last_is_start == true) { return; //起点之间不联通 } is_start = true; s_num++; s_count[(int)seed.seedType - 1] = 1; } else if (type == GridType.WATER) { e_num++; } haveScanned = true; //已经遍历过的标记 for (int i = 1; i <= 4; i++) { LevelGrid tmp = GetNearGrid((NearGridDirection)i); if (tmp == null) { continue; } if (tmp.state > 0 && tmp.haveScanned == false && (tmp.groundColor == groundColor || tmp.groundColor == WaterColor.DEFAULT)) { tmp.Count_s_e(ref s_count, ref s_num, ref e_num, is_start); } } }