コード例 #1
0
        /// <summary>
        /// 分配特定种类资源的采集任务
        /// </summary>
        /// <param name="workType">资源种类</param>
        private void ArrangeWork(WorkType workType)
        {
            var size = int.Parse(df.partWorldMapDate[df.mianPartId][98]); // size of map
            var part = df.mianPartId;

            var maxPlace = -1;
            var maxRes   = 0;
            var manNeed  = 0x7fffffff;
            var manPool  = UIDate.instance.GetUseManPower();

            for (int place = 0; place < size * size; place++)
            {
                if (Explored(part, place) && !df.PlaceIsBad(part, place) && !df.HaveWork(part, place))
                {
                    var res = UIDate.instance.GetWorkPower((int)workType, part, place);
                    var man = int.Parse(df.GetNewMapDate(part, place, 12));
                    if (res > maxRes && manPool >= man)
                    {
                        if (man <= 1 || !Main.Setting.skipTown)
                        {
                            maxRes   = res;
                            maxPlace = place;
                            manNeed  = man;
                        }
                    }
                }
            }
            if (maxRes > 0 && maxPlace >= 0)
            {
                if (manPool >= manNeed)
                {
                    var choosePartId  = wms.choosePartId;
                    var choosePlaceId = wms.choosePlaceId;
                    var chooseWorkTyp = wms.chooseWorkTyp;

                    wms.choosePartId  = part;
                    wms.choosePlaceId = maxPlace;
                    wms.chooseWorkTyp = (int)workType;
                    wms.DoManpowerWork();

                    wms.choosePartId  = choosePartId;
                    wms.choosePlaceId = choosePlaceId;
                    wms.chooseWorkTyp = chooseWorkTyp;
                }
            }
            else
            {
                TipsWindow.instance.SetTips(0, new string[] { "<color=#AF3737FF>无资源可采集或人力不足</color>" }, 180);
            }
        }
コード例 #2
0
        private void ArrangeWork(int workType)
        {
            var size = int.Parse(df.partWorldMapDate[df.mianPartId][98]); // size of map
            var part = df.mianPartId;

            var maxPlace = -1;
            var maxRes   = 0;

            for (int place = 0; place < size * size; place++)
            {
                if (Explored(part, place) && !df.PlaceIsBad(part, place) && !df.HaveWork(part, place))
                {
                    var res = UIDate.instance.GetWorkPower((int)workType, part, place);
                    if (res > maxRes)
                    {
                        maxRes   = res;
                        maxPlace = place;
                    }
                }
            }
            if (maxRes > 0 && maxPlace >= 0)
            {
                var manPool = UIDate.instance.GetUseManPower();
                var manNeed = int.Parse(df.GetNewMapDate(part, maxPlace, 12));
                if (manPool >= manNeed)
                {
                    var choosePartId  = wms.choosePartId;
                    var choosePlaceId = wms.choosePlaceId;
                    var chooseWorkTyp = wms.chooseWorkTyp;

                    wms.choosePartId  = part;
                    wms.choosePlaceId = maxPlace;
                    wms.chooseWorkTyp = workType;
                    wms.DoManpowerWork();

                    wms.choosePartId  = choosePartId;
                    wms.choosePlaceId = choosePlaceId;
                    wms.chooseWorkTyp = chooseWorkTyp;
                    return;
                }
            }
        }
コード例 #3
0
        /// <summary>
        /// 分配特定种类资源的采集任务
        /// </summary>
        /// <param name="workType">资源种类</param>
        private void ArrangeWork(WorkType workType)
        {
            // var part = df.mianPartId;

            var maxPart  = -1;
            var maxPlace = -1;
            var maxRes   = 0;
            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 res = UIDate.instance.GetWorkPower((int)workType, part, place);
                        var man = int.Parse(df.GetNewMapDate(part, place, 12));
                        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)
                {
                    var choosePartId  = wms.choosePartId;
                    var choosePlaceId = wms.choosePlaceId;
                    var chooseWorkTyp = wms.chooseWorkTyp;

                    wms.choosePartId  = maxPart;
                    wms.choosePlaceId = maxPlace;
                    wms.chooseWorkTyp = (int)workType;
                    wms.DoManpowerWork();

                    wms.choosePartId  = choosePartId;
                    wms.choosePlaceId = choosePlaceId;
                    wms.chooseWorkTyp = chooseWorkTyp;
                }
            }
            else
            {
                TipsWindow.instance.SetTips(0,
                                            new string[] { "<color=#AF3737FF>无资源可采集或人力不足</color>" }, 180);
            }
        }