/// <summary> /// 分配特定种类资源的采集任务 /// </summary> /// <param name="workType">资源种类</param> private void ArrangeWork(WorkType workType) { // var part = df.mianPartId; var maxPart = -1; var maxPlace = -1; var maxRes = 0f; var manNeed = 0x7fffffff; var manPool = UIDate.instance.GetUseManPower(); IEnumerable <int> parts = null; switch (Main.Setting.area) { case 1: parts = new int[] { int.Parse(df.GetGangDate(16, 3)) }; break; case 2: parts = df.partWorldMapDate.Keys; break; case 0: default: parts = new int[] { df.mianPartId }; break; } foreach (int part in parts) { var size = int.Parse(df.partWorldMapDate[part][98]); // size of map for (int place = 0; place < size * size; place++) { if (df.HaveShow(part, place) > 0 && !df.PlaceIsBad(part, place) && !df.HaveWork(part, place)) { var man = df.GetMarkNeedManPower(part, place); var res = man == 0 ? 0f : UIDate.instance.GetWorkPower((int)workType, part, place) / (float)man; if (res > maxRes && manPool >= man) { if (man <= 1 || !Main.Setting.skipTown) { maxRes = res; maxPart = part; maxPlace = place; manNeed = man; } } } } } if (maxRes > 0 && maxPart >= 0 && maxPlace >= 0) { if (manPool >= manNeed) { Debug.Log($"开始在{maxPart},{maxPlace}采集{workStr[(int)workType]}"); wms.SetPlaceWork(maxPart, maxPlace, (int)workType); UpdateUiManpower(); } } else { TipsWindow.instance.SetTips(0, new string[] { "<color=#AF3737FF>无资源可采集或人力不足</color>" }, 180); } }