Exemplo n.º 1
0
        /// <summary>
        /// 获取军令数量
        /// </summary>
        /// <param name="dmGuid"></param>
        /// <returns></returns>
        public static int GetPoint(string dmGuid)
        {
            // 首先跳转到主界面
            WlyViewMgr.GoTo(dmGuid, WlyViewType.场景_主界面);
            var pointRect = new WxRect(119, 106, 163, 123);
            var words     = string.Empty;
            var wait      = FlowLogicHelper.RepeatRun(() =>
            {
                words = DMService.Instance.GetWords(dmGuid, pointRect, "f3f3da-202020");
                return(!string.IsNullOrEmpty(words));
            }, TimeSpan.FromSeconds(20));

            if (!wait)
            {
                throw new InvalidOperationException("无法获取军令信息");
            }

            var result = int.TryParse(words.Split('/')[0], out var point);

            if (!result)
            {
                WxLog.Debug($"WlyUtilityBiz.GetPoint  <{words}>");
                return(0);
            }

            return(point);
        }
Exemplo n.º 2
0
        /// <summary>
        /// 获取当前武将等级
        /// </summary>
        /// <param name="dmGuid"></param>
        /// <param name="staff"></param>
        /// <returns></returns>
        public static int GetStaffLevel(string dmGuid, WlyStaffType staff)
        {
            SelectStaff(dmGuid, staff, WlyViewType.功能_训练);

            var levelStr = string.Empty;
            var wait     = FlowLogicHelper.RepeatRun(() =>
            {
                levelStr = DMService.Instance.GetWords(dmGuid, new WxRect(716, 306, 799, 328), "e9e7cf-000000");
                return(!string.IsNullOrEmpty(levelStr));
            }, TimeSpan.FromSeconds(10));

            if (!wait)
            {
                throw new InvalidOperationException("无法解析武将等级");
            }

            var result = int.TryParse(levelStr.Substring(0, levelStr.Length - 1), out var currentLevel);

            if (!result)
            {
                throw new InvalidOperationException("无法解析武将等级");
            }

            return(currentLevel);
        }
Exemplo n.º 3
0
        /// <summary>
        /// 创建角色
        /// </summary>
        /// <param name="name"></param>
        private void CreateRole(string name)
        {
            // 等待进入创建角色界面
            var wait = FlowLogicHelper.RepeatRun(() => DMService.Instance.FindPic(DMGuid, WlyPicType.择国家, WlyUtilityBiz.GameWndRect),
                                                 TimeSpan.FromSeconds(30));

            if (!wait)
            {
                throw new InvalidOperationException("进入创建角色界面失败");
            }

            // 选择吴国
            var wu = new WxPoint(630, 400);

            DMService.Instance.LeftClick(DMGuid, wu);

            // 输入名称
            var namePoint = new WxPoint(517, 504);

            DMService.Instance.LeftDoubleClick(DMGuid, namePoint, 100);
            DMService.Instance.LeftDoubleClick(DMGuid, namePoint, 100);

            var guid = DMService.Instance.CreateDMSoft();

            DMService.Instance.BindWindowIME(guid, WndHwnd);
            DMService.Instance.SendStringIme(guid, name);
            Thread.Sleep(1000);
            DMService.Instance.ReleaseDMSoft(guid);

            // 确定
            var okPoint = new WxPoint(493, 556);

            DMService.Instance.LeftClick(DMGuid, okPoint);
            throw new InvalidOperationException("角色创建完毕需要重启");
        }
Exemplo n.º 4
0
        /// <summary>
        /// 执行任务
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        protected override WlyTaskInfo InternalRun(WlyEntity entity)
        {
            var dmGuid = entity.DMGuid;

            WlyViewMgr.GoTo(dmGuid, WlyViewType.功能_主线任务);

            var wait = FlowLogicHelper.RepeatRun(() =>
            {
                if (DMService.Instance.FindStr(dmGuid, new WxRect(550, 418, 634, 446), "领取|接受",
                                               $"{WlyColor.Normal}|{WlyColor.White}"))
                {
                    DMService.Instance.LeftClick(dmGuid, new WxPoint(592, 436));
                }

                if (DMService.Instance.FindStr(dmGuid, new WxRect(550, 418, 634, 446), "取消",
                                               $"{WlyColor.Normal}|{WlyColor.White}"))
                {
                    return(true);
                }

                return(false);
            }, TimeSpan.FromSeconds(120));

            if (!wait)
            {
                return(new WlyTaskInfo(ID, WlyUtilityBiz.GetRefreshTime()));
            }

            return(new WlyTaskInfo(ID, true));
        }
Exemplo n.º 5
0
        /// <summary>
        /// 执行任务
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        protected override WlyTaskInfo InternalRun(WlyEntity entity)
        {
            var dmGuid = entity.DMGuid;

            WlyViewMgr.GoTo(dmGuid, WlyViewType.场景_主城);
            WlyUtilityBiz.GetPercent(dmGuid, new WxRect(137, 47, 238, 68), "e9e7cf-000000", out var persent);
            if (persent > 0.8)
            {
                return(new WlyTaskInfo(ID, true));

                WlyViewMgr.GoTo(dmGuid, WlyViewType.功能_卖粮);
                DMService.Instance.LeftClick(dmGuid, new WxPoint(760, 343));
                DMService.Instance.LeftClick(dmGuid, new WxPoint(762, 377));
            }

            WlyViewMgr.GoTo(dmGuid, WlyViewType.建筑_农田);

            FlowLogicHelper.RepeatRun(() =>
            {
                if (DMService.Instance.FindColor(dmGuid, "aaaaaa-000000", new WxRect(341, 402, 367, 413)))
                {
                    return(true);
                }

                FlowLogicHelper.RepeatRun(() => DMService.Instance.LeftClick(dmGuid, new WxPoint(350, 407), TimeSpan.FromMilliseconds(100)), 5);
                return(false);
            }, TimeSpan.FromSeconds(10));

            return(new WlyTaskInfo(ID, true));
        }
Exemplo n.º 6
0
        /// <summary>
        /// 绑定游戏窗口
        /// </summary>
        protected void BindGameWnd()
        {
            DMGuid = DMService.Instance.CreateDMSoft();
            try
            {
                var wait = FlowLogicHelper.RepeatRun(() =>
                {
                    var hwnd  = DMService.Instance.FindWindowByProcessId(DMGuid, EntityProcess.Id, "ActiveX", "");
                    var state = DMService.Instance.GetWindowState(DMGuid, hwnd, 2);
                    if (state == 0)
                    {
                        Thread.Sleep(500);
                        return(false);
                    }

                    DMService.Instance.BindWindow(DMGuid, hwnd);
                    WndHwnd = hwnd;
                    return(true);
                }, TimeSpan.FromSeconds(10));
                if (!wait)
                {
                    throw new InvalidOperationException("无法绑定游戏窗口");
                }
            }
            catch
            {
                DMService.Instance.ReleaseDMSoft(DMGuid);
                throw;
            }
        }
Exemplo n.º 7
0
        /// <summary>
        /// 强化装备到指定的等级
        /// </summary>
        /// <param name="dmGuid"></param>
        /// <param name="staff"></param>
        /// <param name="equip"></param>
        /// <param name="targetLevel"></param>
        public static WlyEquipInfo UpgradeEquip(string dmGuid, WlyStaffType staff, WlyEquipType equip, int targetLevel)
        {
            WlyViewMgr.GoTo(dmGuid, WlyViewType.功能_强化装备);
            var result = SelectUpgradeEquipCore(dmGuid, staff, equip);

            if (!result)
            {
                WlyViewMgr.ExitCurrentView(dmGuid, TimeSpan.FromSeconds(10));
                WlyViewMgr.GoTo(dmGuid, WlyViewType.功能_强化装备);
                result = SelectUpgradeEquipCore(dmGuid, staff, equip);
            }

            if (!result)
            {
                return(new WlyEquipInfo
                {
                    Quality = WlyQualityType.Unknow
                });
            }

            // 点击强化
            FlowLogicHelper.RunToTarget(() => GetEquipLevelCore(dmGuid), current => current >= targetLevel,
                                        () => DMService.Instance.LeftClick(dmGuid, new WxPoint(563, 354), TimeSpan.FromMilliseconds(50)));
            return(GetEquipInfo(dmGuid));
        }
Exemplo n.º 8
0
        /// <summary>
        /// 执行任务
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        protected override WlyTaskInfo InternalRun(WlyEntity entity)
        {
            var dmGuid = entity.DMGuid;

            // 跳转到主界面
            WlyViewMgr.GoTo(dmGuid, WlyViewType.场景_主城);

            // 点击购买
            DMService.Instance.LeftClick(dmGuid, new WxPoint(179, 111));

            // 识别花费
            var payStr = string.Empty;
            var wait   = FlowLogicHelper.RepeatRun(() =>
            {
                payStr = DMService.Instance.GetWords(dmGuid, new WxRect(528, 249, 579, 284), "ff6600-101010");
                if (DMService.Instance.FindStr(dmGuid, new WxRect(485, 317, 518, 342), "确定", WlyColor.Normal))
                {
                    DMService.Instance.LeftClick(dmGuid, new WxPoint(495, 330));
                    return(true);
                }

                return(payStr.Contains("金币"));
            }, TimeSpan.FromSeconds(30));

            if (!wait)
            {
                throw new InvalidOperationException("无法识别购买花费");
            }

            // 点击购买或取消
            DMService.Instance.LeftClick(dmGuid, payStr == "0金币" ? new WxPoint(454, 355) : new WxPoint(548, 352));
            return(new WlyTaskInfo(ID, true));
        }
Exemplo n.º 9
0
        /// <summary>
        /// 升级指定的建筑到指定的等级
        /// </summary>
        /// <param name="type"></param>
        /// <param name="level"></param>
        /// <param name="dmGuid"></param>
        /// <returns>消除冷却需要花费的金币数量</returns>
        public static int Upgrade(WlyBuildingType type, int level, string dmGuid)
        {
            FlowLogicHelper.RunToTarget(() => GetBuildingLevel(type, dmGuid), current =>
            {
                if (!string.IsNullOrEmpty(DMService.Instance.GetWords(dmGuid, new WxRect(530, 244, 611, 289), "ff6600-000000")))
                {
                    return(true);
                }

                return(current >= level);
            }, () => DMService.Instance.LeftClick(dmGuid, new WxPoint(663, 228), TimeSpan.FromMilliseconds(200)));

            // 升级建筑
            var costStr = DMService.Instance.GetWords(dmGuid, new WxRect(530, 244, 611, 289), "ff6600-000000");

            if (!string.IsNullOrEmpty(costStr))
            {
                if (!costStr.Contains("金币"))
                {
                    throw new InvalidOperationException("无效的金币数量");
                }

                return(int.Parse(costStr.Substring(0, costStr.Length - 2)));
            }

            return(0);
        }
Exemplo n.º 10
0
        public void SpecialTask()
        {
            try
            {
                WlyUtilityBiz.Login(this);
                BindGameWnd();

                var dmGuid = DMGuid;
                WlyViewMgr.GoTo(dmGuid, WlyViewType.功能_红包);

                // 点击红包
                DMService.Instance.LeftClick(dmGuid, new WxPoint(498, 452), TimeSpan.FromSeconds(2));

                FlowLogicHelper.RepeatRun(() => DMService.Instance.LeftClick(dmGuid, new WxPoint(434, 203)), 6);
                FlowLogicHelper.RepeatRun(() => DMService.Instance.LeftClick(dmGuid, new WxPoint(525, 280)), 6);
                FlowLogicHelper.RepeatRun(() => DMService.Instance.LeftClick(dmGuid, new WxPoint(485, 349)), 6);
            }
            catch
            {
            }
            finally
            {
                CloseProcess();
            }
        }
Exemplo n.º 11
0
        /// <summary>
        /// 执行任务
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        protected override WlyTaskInfo InternalRun(WlyEntity entity)
        {
            var endTime = new DateTime(2018, 7, 16, 4, 0, 0);

            if (DateTime.Now > endTime)
            {
                return(new WlyTaskInfo(ID, true));
            }

            var dmGuid = entity.DMGuid;

            WlyViewMgr.GoTo(dmGuid, WlyViewType.功能_厉兵秣马);

            // 领取两个大包厢
            DMService.Instance.LeftClick(dmGuid, new WxPoint(228, 227));
            DMService.Instance.LeftClick(dmGuid, new WxPoint(227, 328));

            // 循环领取七天的奖励
            var start = new WxPoint(375, 177);

            for (var i = 0; i < 7; i++)
            {
                DMService.Instance.LeftClick(dmGuid, start.Shift(70 * i, 0), TimeSpan.FromSeconds(1));
                FlowLogicHelper.RepeatRun(() =>
                {
                    var rect  = new WxRect(733, 290, 790, 312);
                    var point = new WxPoint(761, 299);

                    Thread.Sleep(1000);
                    if (DMService.Instance.FindStr(dmGuid, new WxRect(357, 300, 436, 320), "打猎", "fffdd4-000000"))
                    {
                        rect  = new WxRect(732, 378, 792, 400);
                        point = new WxPoint(759, 388);
                    }

                    if (DMService.Instance.FindStr(dmGuid, rect, "领取奖励", WlyColor.Normal, WlyColor.White))
                    {
                        DMService.Instance.LeftClick(dmGuid, point);
                        return(false);
                    }

                    if (DMService.Instance.FindStr(dmGuid, rect, "前往", WlyColor.Normal))
                    {
                        return(true);
                    }

                    if (DMService.Instance.FindStr(dmGuid, new WxRect(485, 317, 518, 342), "确定", WlyColor.Normal))
                    {
                        DMService.Instance.LeftClick(dmGuid, new WxPoint(495, 330));
                    }

                    return(false);
                }, TimeSpan.FromSeconds(10));
            }

            return(new WlyTaskInfo(ID, true));
        }
Exemplo n.º 12
0
        /// <summary>
        /// 执行任务
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        protected override WlyTaskInfo InternalRun(WlyEntity entity)
        {
            var dmGuid = entity.DMGuid;

            WlyViewMgr.GoTo(dmGuid, WlyViewType.功能_商城);

            DMService.Instance.LeftClick(dmGuid, new WxPoint(559, 468));
            var costStr = string.Empty;
            var wait    = FlowLogicHelper.RepeatRun(() =>
            {
                costStr = DMService.Instance.GetWords(dmGuid, new WxRect(473, 265, 518, 285), "ffff00-101010");
                return(costStr.Contains("金币"));
            }, TimeSpan.FromSeconds(5));

            if (!wait)
            {
                throw new InvalidOperationException("无法确认商城刷新的花费");
            }

            if (costStr == "10金币")
            {
                DMService.Instance.LeftClick(dmGuid, new WxPoint(460, 357), TimeSpan.FromSeconds(2));

                // 购买所有可以使用粮食和银币购买的东西
                var itemRects = new List <WxRect>
                {
                    new WxRect(262, 301, 332, 327),
                    new WxRect(411, 304, 472, 325),
                    new WxRect(551, 304, 619, 326),
                    new WxRect(266, 418, 329, 439),
                    new WxRect(408, 417, 474, 440),
                    new WxRect(556, 417, 617, 442)
                };

                foreach (var rect in itemRects)
                {
                    if (WlyUtilityBiz.GetAmount(dmGuid, rect, "ffffff-000000", out var _))
                    {
                        DMService.Instance.LeftClick(dmGuid, new WxPoint(rect.Left, rect.Top));
                        DMService.Instance.LeftClick(dmGuid, new WxPoint(415, 470));

                        if (DMService.Instance.FindStr(dmGuid, new WxRect(434, 338, 473, 366), "确定", WlyColor.Normal))
                        {
                            DMService.Instance.LeftClick(dmGuid, new WxPoint(459, 311));
                            DMService.Instance.LeftClick(dmGuid, new WxPoint(457, 351));
                        }
                    }
                }
            }
            else
            {
                DMService.Instance.LeftClick(dmGuid, new WxPoint(547, 353));
            }

            return(new WlyTaskInfo(ID, true));
        }
Exemplo n.º 13
0
        /// <summary>
        /// 执行任务
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        protected override WlyTaskInfo InternalRun(WlyEntity entity)
        {
            var dmGuid = entity.DMGuid;

            if (DMService.Instance.FindStr(dmGuid, new WxRect(511, 176, 548, 199), "物品", WlyColor.Normal))
            {
                var equip = WlyEquipMgr.GetEquipInfo(dmGuid);
                // 每次重铸执行100次
                for (var i = 0; i < 1000; i++)
                {
                    DMService.Instance.LeftClick(dmGuid, new WxPoint(555, 428));
                    FlowLogicHelper.RepeatRun(() =>
                    {
                        if (equip.Type == WlyEquipType.带兵量)
                        {
                            if (DMService.Instance.FindColor(dmGuid, "20ef4c-000000", new WxRect(780, 412, 798, 427)))
                            {
                                DMService.Instance.LeftClick(dmGuid, new WxPoint(584, 425), TimeSpan.FromSeconds(1));
                                return(true);
                            }

                            if (DMService.Instance.FindColor(dmGuid, "ff0000-000000", new WxRect(780, 412, 798, 427)))
                            {
                                DMService.Instance.LeftClick(dmGuid, new WxPoint(502, 428));
                                return(true);
                            }
                        }
                        else
                        {
                            if (DMService.Instance.FindColor(dmGuid, "20ef4c-000000", new WxRect(780, 437, 798, 453)))
                            {
                                DMService.Instance.LeftClick(dmGuid, new WxPoint(584, 425), TimeSpan.FromSeconds(1));
                                return(true);
                            }



                            if (DMService.Instance.FindColor(dmGuid, "ff0000-000000", new WxRect(780, 437, 798, 453)))
                            {
                                DMService.Instance.LeftClick(dmGuid, new WxPoint(502, 428));
                                return(true);
                            }
                        }

                        Thread.Sleep(500);

                        return(true);
                    }, TimeSpan.FromSeconds(5));
                }
            }

            return(new WlyTaskInfo(ID, true));
        }
Exemplo n.º 14
0
        /// <summary>
        /// 执行任务
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        protected override WlyTaskInfo InternalRun(WlyEntity entity)
        {
            var dmGuid = entity.DMGuid;

            WlyViewMgr.GoTo(dmGuid, WlyViewType.场景_世界地图);

            // 确认投资冷却时间
            if (DMService.Instance.FindStr(dmGuid, new WxRect(100, 212, 145, 234), "可投资", "20ef4c-000000"))
            {
                WlyMapMgr.OpenCity(dmGuid, m_city);
                var s1 = DMService.Instance.GetWords(dmGuid, new WxRect(470, 352, 565, 370), "e9e7cf-000000");
                var v1 = int.Parse(s1.Split('/')[0]);
                WlyUtilityBiz.SystemInfo.Develop1 = v1;

                var s2 = DMService.Instance.GetWords(dmGuid, new WxRect(470, 374, 565, 939), "e9e7cf-000000");
                var v2 = int.Parse(s2.Split('/')[0]);
                WlyUtilityBiz.SystemInfo.Develop2 = v2;
                WlyUtilityBiz.SystemInfo.Save();

                var wait = FlowLogicHelper.RepeatRun(() =>
                {
                    if (DMService.Instance.FindStr(dmGuid, new WxRect(470, 214, 494, 236), "城", WlyColor.Normal))
                    {
                        return(true);
                    }

                    DMService.Instance.LeftClick(dmGuid, new WxPoint(660, 277));
                    return(false);
                }, TimeSpan.FromSeconds(5));
                if (!wait)
                {
                    throw new InvalidOperationException("无法打开城池进行开发");
                }

                if (v1 > v2)
                {
                    DMService.Instance.LeftClick(dmGuid, new WxPoint(583, 267));
                    DMService.Instance.LeftClick(dmGuid, new WxPoint(536, 301));
                }

                DMService.Instance.LeftClick(dmGuid, new WxPoint(440, 367), TimeSpan.FromSeconds(2));
            }

            if (!DMService.Instance.FindColor(dmGuid, "33ffff-000000", new WxRect(100, 212, 160, 234)))
            {
                return(new WlyTaskInfo(ID, WlyUtilityBiz.GetRefreshTime()));
            }

            var coolTime = WlyUtilityBiz.GetTime(dmGuid, new WxRect(100, 212, 160, 234), "33ffff-000000");

            return(new WlyTaskInfo(ID, DateTime.Now.Add(coolTime)));
        }
Exemplo n.º 15
0
        /// <summary>
        /// 执行任务
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        protected override WlyTaskInfo InternalRun(WlyEntity entity)
        {
            var dmGuid = entity.DMGuid;

            WlyViewMgr.GoTo(dmGuid, WlyViewType.场景_竞技场);
            Thread.Sleep(1000);
            if (DMService.Instance.FindColor(dmGuid, "ff0000-000000", new WxRect(436, 470, 486, 484)))
            {
                return(new WlyTaskInfo(ID, true));
            }

            FlowLogicHelper.RepeatRun(() =>
            {
                if (!DMService.Instance.FindStr(dmGuid, new WxRect(108, 207, 174, 229), "查看奖励", "ffcc00-000000"))
                {
                    DMService.Instance.LeftClick(dmGuid, new WxPoint(141, 214));
                    DMService.Instance.LeftClick(dmGuid, new WxPoint(454, 330));
                    return(false);
                }

                return(true);
            }, TimeSpan.FromSeconds(10));

            if (WlyUtilityBiz.GetAmount(dmGuid, new WxRect(167, 156, 219, 175), "ff9900-000000", out var amount))
            {
                entity.AccountInfo.FightPoint = amount;
            }

            var result = WlyUtilityBiz.GetAmount(dmGuid, new WxRect(366, 268, 401, 289), WlyColor.White, out var targetLevel);

            if (result && targetLevel > entity.AccountInfo.GetBuildingInfo(WlyBuildingType.主城).Level)
            {
                return(new WlyTaskInfo(ID, true));
            }

            DMService.Instance.LeftClick(dmGuid, new WxPoint(621, 558));
            DMService.Instance.LeftClick(dmGuid, new WxPoint(455, 330));

            DMService.Instance.LeftClick(dmGuid, new WxPoint(499, 386));
            var enemy = DMService.Instance.GetWords(dmGuid, new WxRect(323, 247, 383, 269), "ffffff-000000");

            if (enemy.Contains("海潮"))
            {
                return(new WlyTaskInfo(ID, true));
            }

            DMService.Instance.LeftClick(dmGuid, new WxPoint(354, 325));
            DMService.Instance.LeftClick(dmGuid, new WxPoint(454, 328));

            // 直接结束,不再等待
            throw new InvalidOperationException();
        }
Exemplo n.º 16
0
        /// <summary>
        /// 执行任务
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        protected override WlyTaskInfo InternalRun(WlyEntity entity)
        {
            var dmGuid = entity.DMGuid;

            WlyViewMgr.GoTo(dmGuid, WlyViewType.功能_主公属性);

            // 升级经济
            var wait = FlowLogicHelper.RepeatRun(() =>
            {
                DMService.Instance.LeftClick(dmGuid, new WxPoint(375, 160));
                return(DMService.Instance.FindStr(dmGuid, new WxRect(485, 188, 518, 206), "经济", "ffcc00-000000"));
            }, TimeSpan.FromSeconds(5));

            if (!wait)
            {
                throw new InvalidOperationException("无法打开主公属性经济");
            }

            var key    = false;
            var result = WlyUtilityBiz.GetAmount(dmGuid, new WxRect(659, 304, 710, 329), WlyColor.White, out var amount);

            if (result && (amount > 0))
            {
                key = true;
            }

            //result = WlyUtilityBiz.GetAmount(dmGuid, new WxRect(663, 355, 705, 379), WlyColor.White, out amount);
            //if (result && (amount > 0))
            //{
            //    key = true;
            //}

            //result = WlyUtilityBiz.GetAmount(dmGuid, new WxRect(662, 409, 706, 432), WlyColor.White, out amount);
            //if (result && (amount > 0))
            //{
            //    key = true;
            //}

            if (key)
            {
                DMService.Instance.LeftClick(dmGuid, new WxPoint(507, 474));
                DMService.Instance.LeftClick(dmGuid, new WxPoint(454, 331));
                entity.AccountInfo.ResetMainLevel();
                entity.AccountInfo.Save();
                throw new InvalidOperationException();
            }

            return(new WlyTaskInfo(ID, true));
        }
Exemplo n.º 17
0
        /// <summary>
        /// 执行任务
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        protected override WlyTaskInfo InternalRun(WlyEntity entity)
        {
            var dmGuid = entity.DMGuid;

            WlyViewMgr.GoTo(dmGuid, WlyViewType.功能_卖粮);

            // 读取粮价
            var priceRect = new WxRect(386, 211, 479, 232);
            var priceStr  = string.Empty;
            var wait      = FlowLogicHelper.RepeatRun(() =>
            {
                priceStr = DMService.Instance.GetWords(dmGuid, priceRect, "e9e7cf-000000");
                return(!string.IsNullOrEmpty(priceStr));
            }, TimeSpan.FromSeconds(10));

            if (!wait)
            {
                throw new InvalidOperationException("无法读取当前粮价");
            }

            var info = WlyUtilityBiz.SystemInfo;

            info.FoodPriceDescription = $"{priceStr} [{DateTime.Now:yyyy-MM-dd HH:mm:ss}]";
            if (double.TryParse(priceStr.Split('(')[0], out var price))
            {
                info.FoodPrice = price;
            }

            // 如果达到最高价则卖粮
            if (price >= 1.8)
            {
                DMService.Instance.LeftClick(dmGuid, new WxPoint(760, 343));
                DMService.Instance.LeftClick(dmGuid, new WxPoint(762, 377));
            }

            if (price <= 0.65)
            {
                DMService.Instance.LeftClick(dmGuid, new WxPoint(759, 421));
                DMService.Instance.LeftClick(dmGuid, new WxPoint(761, 454));
                return(new WlyTaskInfo(ID, DateTime.Now.AddMinutes(9)));
            }

            var now      = DateTime.Now;
            var flag     = DateTime.Today.AddHours(now.Hour).AddMinutes(30);
            var nextTime = now < flag?flag.AddMinutes(1) : flag.AddMinutes(31);

            info.NextFoodTime = nextTime;
            return(new WlyTaskInfo(ID, nextTime));
        }
Exemplo n.º 18
0
        /// <summary>
        /// 领取红包的任务
        /// </summary>
        /// <param name="entity"></param>
        public static void SpecialTask(WlyEntity entity)
        {
            Login(entity);

            var dmGuid = entity.DMGuid;

            WlyViewMgr.GoTo(dmGuid, WlyViewType.功能_红包);

            // 点击红包
            DMService.Instance.LeftClick(dmGuid, new WxPoint(498, 452), TimeSpan.FromSeconds(2));

            FlowLogicHelper.RepeatRun(() => DMService.Instance.LeftClick(dmGuid, new WxPoint(434, 203)), 6);
            FlowLogicHelper.RepeatRun(() => DMService.Instance.LeftClick(dmGuid, new WxPoint(525, 280)), 6);
            FlowLogicHelper.RepeatRun(() => DMService.Instance.LeftClick(dmGuid, new WxPoint(485, 349)), 6);
        }
Exemplo n.º 19
0
        /// <summary>
        /// 执行任务
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        protected override WlyTaskInfo InternalRun(WlyEntity entity)
        {
            var dmGuid = entity.DMGuid;

            WlyViewMgr.GoTo(dmGuid, WlyViewType.场景_主界面);

            var rect = new WxRect(99, 253, 134, 275);

            if (!FlowLogicHelper.RepeatRun(() =>
            {
                DMService.Instance.LeftDown(dmGuid, new WxPoint(89, 225));

                return(DMService.Instance.FindStr(dmGuid, rect, "开通", "ff8c00-000000") ||
                       DMService.Instance.FindStr(dmGuid, rect, "空闲", "1fed4a-000000"));
            }, TimeSpan.FromSeconds(10)))
            {
                throw new InvalidOperationException("无法开通");
            }

            if (DMService.Instance.FindStr(dmGuid, rect, "开通", "ff8c00-000000"))
            {
                DMService.Instance.LeftClick(dmGuid, new WxPoint(116, 263));
                DMService.Instance.LeftClick(dmGuid, new WxPoint(455, 355));
                DMService.Instance.LeftUp(dmGuid, new WxPoint(89, 225));
            }

            Thread.Sleep(2000);
            rect = new WxRect(99, 273, 134, 299);
            if (!FlowLogicHelper.RepeatRun(() =>
            {
                DMService.Instance.LeftDown(dmGuid, new WxPoint(89, 225));

                return(DMService.Instance.FindStr(dmGuid, rect, "开通", "ff8c00-000000") ||
                       DMService.Instance.FindStr(dmGuid, rect, "空闲", "1fed4a-000000"));
            }, TimeSpan.FromSeconds(10)))
            {
                throw new InvalidOperationException("无法开通");
            }

            if (DMService.Instance.FindStr(dmGuid, rect, "开通", "ff8c00-000000"))
            {
                DMService.Instance.LeftClick(dmGuid, new WxPoint(118, 285));
                DMService.Instance.LeftClick(dmGuid, new WxPoint(455, 355));
                DMService.Instance.LeftUp(dmGuid, new WxPoint(89, 225));
            }

            return(new WlyTaskInfo(ID, true));
        }
Exemplo n.º 20
0
        /// <summary>
        /// 执行任务
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        protected override WlyTaskInfo InternalRun(WlyEntity entity)
        {
            var dmGuid = entity.DMGuid;

            WlyViewMgr.GoTo(dmGuid, WlyViewType.功能_主线任务);
            FlowLogicHelper.RepeatRun(() =>
            {
                if (DMService.Instance.FindStr(dmGuid, new WxRect(550, 418, 634, 446), "领取|接受",
                                               $"{WlyColor.Normal}|{WlyColor.White}"))
                {
                    DMService.Instance.LeftClick(dmGuid, new WxPoint(592, 436));
                }

                if (DMService.Instance.FindStr(dmGuid, new WxRect(550, 418, 634, 446), "取消",
                                               $"{WlyColor.Normal}|{WlyColor.White}"))
                {
                    return(true);
                }

                return(false);
            }, TimeSpan.FromSeconds(20));

            WlyViewMgr.GoTo(dmGuid, WlyViewType.功能_每日任务);
            var key = false;

            FlowLogicHelper.RepeatRun(() =>
            {
                if (DMService.Instance.FindColor(dmGuid, "4bd8b0-000000", new WxRect(765, 244, 784, 261)))
                {
                    DMService.Instance.LeftClick(dmGuid, new WxPoint(721, 220));
                }

                if (DMService.Instance.FindColor(dmGuid, "418674-000000", new WxRect(765, 244, 784, 261)))
                {
                    return(true);
                }

                if (DMService.Instance.FindColor(dmGuid, "101b19-000000", new WxRect(new WxPoint(682, 192), 10, 10)))
                {
                    key = true;
                    return(true);
                }

                return(false);
            }, TimeSpan.FromSeconds(20));

            return(key ? new WlyTaskInfo(ID, true) : new WlyTaskInfo(ID, DateTime.Now.Add(m_interval)));
        }
Exemplo n.º 21
0
        /// <summary>
        /// 获取装备等级
        /// </summary>
        /// <param name="dmGuid"></param>
        /// <returns></returns>
        private static int GetEquipLevelCore(string dmGuid)
        {
            var levelStr = string.Empty;
            var wait     = FlowLogicHelper.RepeatRun(() =>
            {
                levelStr = DMService.Instance.GetWords(dmGuid, new WxRect(713, 289, 812, 313), "e9e7cf-000000");
                return(!string.IsNullOrEmpty(levelStr));
            }, TimeSpan.FromSeconds(10));

            if (!wait || !levelStr.Contains("级") || !int.TryParse(levelStr.Substring(0, levelStr.Length - 1), out var currentLevel))
            {
                throw new InvalidOperationException("无法解析装备等级");
            }

            return(currentLevel);
        }
Exemplo n.º 22
0
        /// <summary>
        /// 执行任务
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        protected override WlyTaskInfo InternalRun(WlyEntity entity)
        {
            var dmGuid = entity.DMGuid;

            WlyViewMgr.GoTo(dmGuid, WlyViewType.功能_生产);
            Thread.Sleep(1000);

            // 勾选使用3金币进行暴击
            if (!DMService.Instance.FindColor(dmGuid, WlyColor.Normal, new WxRect(534, 236, 566, 255)))
            {
                DMService.Instance.LeftClick(dmGuid, new WxPoint(520, 245));
            }

            var wait = FlowLogicHelper.RepeatRun(() =>
            {
                var result = WlyUtilityBiz.GetAmount(dmGuid, new WxRect(575, 420, 599, 437), "f3f3da-000000", out var amount);
                if (result && (amount == 0))
                {
                    return(true);
                }

                if (DMService.Instance.FindStr(dmGuid, new WxRect(458, 260, 521, 294), "金币", "ffff00-000000"))
                {
                    DMService.Instance.LeftClick(dmGuid, new WxPoint(545, 357));
                }

                FlowLogicHelper.RepeatRun(() => DMService.Instance.LeftClick(dmGuid, new WxPoint(554, 457), TimeSpan.FromMilliseconds(200)), amount);
                Thread.Sleep(1000);
                return(false);
            }, TimeSpan.FromSeconds(30));

            if (wait)
            {
                Thread.Sleep(1000);
                if (DMService.Instance.FindStr(dmGuid, new WxRect(531, 342, 561, 364), "取消", WlyColor.Normal))
                {
                    DMService.Instance.LeftClick(dmGuid, new WxPoint(548, 353));
                }

                // 卖出商品
                DMService.Instance.LeftClick(dmGuid, new WxPoint(710, 456));

                return(new WlyTaskInfo(ID, true));
            }

            return(new WlyTaskInfo(ID, DateTime.Now.AddHours(1)));
        }
Exemplo n.º 23
0
        /// <summary>
        /// 征召士兵
        /// </summary>
        /// <param name="dmGuid"></param>
        public static void GetSoldier(string dmGuid)
        {
            WlyViewMgr.GoTo(dmGuid, WlyViewType.功能_征兵);
            FlowLogicHelper.RepeatRun(() =>
            {
                if (DMService.Instance.FindStr(dmGuid, new WxRect(634, 410, 704, 439), "募集", $"{WlyColor.Normal}|{WlyColor.White}"))
                {
                    FlowLogicHelper.RepeatRun(() => DMService.Instance.LeftClick(dmGuid, new WxPoint(664, 425), TimeSpan.FromMilliseconds(100)), 10);
                    return(false);
                }

                return(true);
            }, TimeSpan.FromSeconds(10));

            DMService.Instance.LeftClick(dmGuid, new WxPoint(562, 261));
            DMService.Instance.LeftClick(dmGuid, new WxPoint(666, 292));
        }
Exemplo n.º 24
0
        /// <summary>
        /// 执行任务
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        protected override WlyTaskInfo InternalRun(WlyEntity entity)
        {
            var dmGuid = entity.DMGuid;

            WlyViewMgr.GoTo(dmGuid, WlyViewType.功能_委派);

            // 主城等级大于100时自动卖出
            if (entity.AccountInfo.GetBuildingInfo(WlyBuildingType.主城).Level >= 100)
            {
                // 设置自动卖出
                DMService.Instance.LeftClick(dmGuid, new WxPoint(251, 473));
                DMService.Instance.LeftClick(dmGuid, new WxPoint(442, 341));
                DMService.Instance.LeftClick(dmGuid, new WxPoint(493, 395));
            }

            // 开始委派
            var wait = FlowLogicHelper.RepeatRun(() =>
            {
                if (WlyUtilityBiz.GetAmount(dmGuid, new WxRect(294, 429, 312, 449), "fce69a-000000", out var count) && (count == 0))
                {
                    return(true);
                }

                if (DMService.Instance.FindStr(dmGuid, new WxRect(524, 338, 569, 367), "取消", WlyColor.Normal))
                {
                    DMService.Instance.LeftClick(dmGuid, new WxPoint(548, 351));
                }

                FlowLogicHelper.RepeatRun(() => DMService.Instance.LeftClick(dmGuid, new WxPoint(257, 368), TimeSpan.FromMilliseconds(200)), count);
                Thread.Sleep(1000);
                return(false);
            }, TimeSpan.FromSeconds(30));

            if (DMService.Instance.FindStr(dmGuid, new WxRect(483, 384, 517, 409), "免费", "ffff00-000000"))
            {
                DMService.Instance.LeftClick(dmGuid, new WxPoint(496, 367));
            }

            if (wait)
            {
                return(new WlyTaskInfo(ID, true));
            }

            return(new WlyTaskInfo(ID, DateTime.Now.Add(TimeSpan.FromMinutes(30))));
        }
Exemplo n.º 25
0
        /// <summary>
        /// 从当前界面退出
        /// </summary>
        /// <param name="dmGuid"></param>
        public override void Exit(string dmGuid)
        {
            FlowLogicHelper.RepeatRun(() =>
            {
                if (DMService.Instance.FindStr(dmGuid, new WxRect(803, 220, 863, 241), "领取奖励", "1fed4a-000000", WlyColor.White))
                {
                    DMService.Instance.LeftClick(dmGuid, new WxPoint(829, 232), TimeSpan.FromSeconds(1));
                    if (DMService.Instance.FindStr(dmGuid, new WxRect(475, 360, 535, 380), "领取奖励", WlyColor.Normal))
                    {
                        DMService.Instance.LeftClick(dmGuid, new WxPoint(504, 371));
                    }
                    return(false);
                }

                return(true);
            }, TimeSpan.FromSeconds(15));

            DMService.Instance.LeftClick(dmGuid, m_exit);
        }
Exemplo n.º 26
0
        /// <summary>
        /// 打开指定的城池
        /// </summary>
        /// <param name="dmGuid"></param>
        /// <param name="city"></param>
        public static void OpenCity(string dmGuid, WlyCityType city)
        {
            WlyViewMgr.GoTo(dmGuid, WlyViewType.场景_世界地图);

            var find = DMService.Instance.FindStr(dmGuid, WlyUtilityBiz.GameWndRect, city.ToString(), "f3f3da-000000", out var x,
                                                  out var y);

            if (!find)
            {
                throw new InvalidOperationException($"未找到城池{city.ToString()}");
            }

            DMService.Instance.LeftClick(dmGuid, new WxPoint(x + 20, y - 20));
            var wait = FlowLogicHelper.RepeatRun(
                () => DMService.Instance.FindStr(dmGuid, new WxRect(485, 148, 518, 173), city.ToString(), WlyColor.Normal),
                TimeSpan.FromSeconds(5));

            if (!wait)
            {
                throw new InvalidOperationException($"无法打开城池{city.ToString()}");
            }
        }
Exemplo n.º 27
0
        /// <summary>
        /// 设置阵型
        /// </summary>
        /// <param name="type"></param>
        /// <param name="dmGuid"></param>
        public static void SetFormation(WlyFormationType type, string dmGuid)
        {
            WlyViewMgr.GoTo(dmGuid, WlyViewType.功能_阵型);

            var wait = FlowLogicHelper.RepeatRun(() =>
            {
                if (DMService.Instance.FindStr(dmGuid, new WxRect(386, 432, 438, 453), type.ToString(), "f3f3da-000000"))
                {
                    return(true);
                }

                DMService.Instance.LeftClick(dmGuid, _formationMap[type]);
                DMService.Instance.LeftClick(dmGuid, new WxPoint(599, 463));
                return(false);
            }, TimeSpan.FromSeconds(5));

            if (!wait)
            {
                throw new InvalidOperationException("无法设置指定阵型");
            }
            DMService.Instance.LeftClick(dmGuid, new WxPoint(500, 322));
        }
Exemplo n.º 28
0
        /// <summary>
        /// 退出当前界面
        /// </summary>
        /// <param name="dmGuid"></param>
        /// <param name="timeout"></param>
        public static void ExitCurrentView(string dmGuid, TimeSpan timeout)
        {
            IWlyUIView current = null;
            var        wait    = FlowLogicHelper.RepeatRun(() =>
            {
                foreach (var v in _viewList)
                {
                    if (v.IsCurrentView(dmGuid))
                    {
                        current = v;
                        return(true);
                    }
                }

                return(false);
            }, timeout);

            if (!wait)
            {
                throw new InvalidOperationException("无法确定当前所属界面");
            }

            wait = FlowLogicHelper.RepeatRun(() =>
            {
                if (current.IsCurrentView(dmGuid))
                {
                    current.Exit(dmGuid);
                    Thread.Sleep(400);
                    return(false);
                }

                return(true);
            }, timeout);
            if (!wait)
            {
                throw new InvalidOperationException("无法从当前界面退出");
            }
        }
Exemplo n.º 29
0
        /// <summary>
        /// 执行任务
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        protected override WlyTaskInfo InternalRun(WlyEntity entity)
        {
            var dmGuid = entity.DMGuid;

            WlyViewMgr.GoTo(dmGuid, WlyViewType.功能_古代战场);
            DMService.Instance.LeftClick(dmGuid, new WxPoint(493, 444));

            var wait = FlowLogicHelper.RepeatRun(() => DMService.Instance.FindStr(dmGuid, new WxRect(449, 77, 504, 94), "剩余时间", "00fc39-000000"),
                                                 TimeSpan.FromSeconds(60));

            if (!wait)
            {
                throw new InvalidOperationException("无法进入古代战场");
            }

            DMService.Instance.LeftClick(dmGuid, new WxPoint(125, 500), TimeSpan.FromSeconds(2));
            if (DMService.Instance.FindStr(dmGuid, new WxRect(331, 373, 360, 393), "战", WlyColor.Normal))
            {
                DMService.Instance.RepeatLeftClick(dmGuid, new WxPoint(344, 382), 6, 10);
                var view = WlyViewMgr.GetView(WlyViewType.场景_战斗);

                FlowLogicHelper.RepeatRun(() =>
                {
                    if (view.IsCurrentView(dmGuid))
                    {
                        view.Exit(dmGuid);
                        return(true);
                    }

                    return(false);
                }, TimeSpan.FromSeconds(30));
                Thread.Sleep(5000);
            }

            DMService.Instance.LeftClick(dmGuid, new WxPoint(913, 560));
            return(new WlyTaskInfo(ID, true));
        }
Exemplo n.º 30
0
        /// <summary>
        /// 执行任务
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        protected override WlyTaskInfo InternalRun(WlyEntity entity)
        {
            var dmGuid = entity.DMGuid;

            WlyViewMgr.GoTo(dmGuid, WlyViewType.功能_巡查);

            while (true)
            {
                // 获取剩余巡查次数
                var countRect = new WxRect(463, 447, 498, 464);
                var countStr  = DMService.Instance.GetWords(dmGuid, countRect, "20ef4c-000000");
                var count     = int.Parse(countStr.Split('/')[0]);
                if (count == 0)
                {
                    return(new WlyTaskInfo(ID, true));
                }

                FlowLogicHelper.RepeatRun(() => DMService.Instance.LeftClick(dmGuid, new WxPoint(755, 459), TimeSpan.FromMilliseconds(200)), count);
                if (DMService.Instance.FindStr(dmGuid, new WxRect(479, 344, 519, 364), "确定", WlyColor.Normal))
                {
                    DMService.Instance.LeftClick(dmGuid, new WxPoint(497, 355));
                }
            }
        }