/// <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))); }
/// <summary> /// 训练武将 /// </summary> /// <param name="staff"></param> /// <param name="dmGuid"></param> public static void PractiseStaff(WlyStaffType staff, string dmGuid) { SelectStaff(dmGuid, staff, WlyViewType.功能_训练); // 确认是否需要开启武将训练位 while (true) { var word = DMService.Instance.GetWords(dmGuid, new WxRect(198, 457, 236, 489), "f3f3da-000000"); if (word.Contains("/") && (word.Split('/')[1] != "5")) { DMService.Instance.LeftClick(dmGuid, new WxPoint(271, 478)); DMService.Instance.LeftClick(dmGuid, new WxPoint(455, 355), TimeSpan.FromSeconds(2)); continue; } break; } // 确认武将是否正在训练 var lastTime = WlyUtilityBiz.GetTime(dmGuid, new WxRect(566, 287, 636, 308), "33ffff-000000"); if ((lastTime < TimeSpan.FromHours(6)) && (lastTime != TimeSpan.Zero)) { // 结束训练 DMService.Instance.LeftClick(dmGuid, new WxPoint(580, 331), TimeSpan.FromSeconds(1)); DMService.Instance.LeftClick(dmGuid, new WxPoint(453, 331), TimeSpan.FromSeconds(1)); lastTime = WlyUtilityBiz.GetTime(dmGuid, new WxRect(566, 287, 636, 308), "33ffff-000000"); } if (lastTime == TimeSpan.Zero) { // 选择24小时训练 if (!DMService.Instance.FindStr(dmGuid, new WxRect(410, 236, 447, 257), "24", "e9e7cf-000000")) { DMService.Instance.LeftClick(dmGuid, new WxPoint(475, 246)); DMService.Instance.LeftClick(dmGuid, new WxPoint(437, 280)); } // 选择地狱训练 if (!DMService.Instance.FindStr(dmGuid, new WxRect(408, 261, 448, 285), "地狱", "e9e7cf-000000")) { DMService.Instance.LeftClick(dmGuid, new WxPoint(477, 272)); DMService.Instance.LeftClick(dmGuid, new WxPoint(438, 338)); } // 点击训练 DMService.Instance.LeftClick(dmGuid, new WxPoint(580, 331)); } }
/// <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 (WlyUtilityBiz.GetAmount(dmGuid, new WxRect(642, 561, 663, 588), "31f101-000000", out var count) && (count == 0)) { return(new WlyTaskInfo(ID, DateTime.Now.AddMinutes(30))); } var targets = DMService.Instance.FindPics(dmGuid, WlyPicType.打劫目标, new WxRect(110, 179, 931, 536)); foreach (var target in targets) { DMService.Instance.LeftClick(dmGuid, target); var wait = DMService.Instance.FindStr(dmGuid, new WxRect(110, 179, 931, 536), "名称", WlyColor.Normal, out var x, out var y); if (!wait) { continue; } if (DMService.Instance.FindStr(dmGuid, new WxRect(x - 5, y - 5, x + 150, y + 50), "墨君", WlyColor.White)) { var nextTime = WlyUtilityBiz.GetTime(dmGuid, new WxRect(x, y, x + 100, y + 100), WlyColor.Selected); if (nextTime == TimeSpan.Zero) { DMService.Instance.LeftClick(dmGuid, new WxPoint(706, 577)); nextTime = TimeSpan.FromMinutes(10); } if (DMService.Instance.FindStr(dmGuid, new WxRect(480, 318, 519, 342), "确定", WlyColor.Normal)) { DMService.Instance.LeftClick(dmGuid, new WxPoint(499, 331)); } return(new WlyTaskInfo(ID, DateTime.Now.Add(nextTime))); } } return(new WlyTaskInfo(ID, DateTime.Now.AddMinutes(30))); }
/// <summary> /// 执行任务 /// </summary> /// <param name="entity"></param> /// <returns></returns> protected override WlyTaskInfo InternalRun(WlyEntity entity) { var dmGuid = entity.DMGuid; // 首先跳转到主界面 WlyViewMgr.GoTo(dmGuid, WlyViewType.场景_资源区); // 占领指定资源,返回下次检测时间 DateTime OccupyPos(int x, int y) { var res = FlowLogicHelper.RepeatRun(() => { DMService.Instance.LeftClick(dmGuid, new WxPoint(x, y)); return(DMService.Instance.FindStr(dmGuid, new WxRect(365, 212, 426, 238), "产量", "ccf0c1-000000")); }, TimeSpan.FromSeconds(5)); if (!res) { throw new InvalidOperationException($"无法打开资源点"); } // 确认是否为自己拥有 var owner = FlowLogicHelper.RepeatRun( () => DMService.Instance.FindStr(dmGuid, new WxRect(426, 283, 554, 306), "海潮", WlyColor.Normal), TimeSpan.FromSeconds(3)); // 确认是否空闲 if (!owner) { var local = FlowLogicHelper.RepeatRun( () => DMService.Instance.FindStr(dmGuid, new WxRect(426, 283, 554, 306), "地方势力", WlyColor.Normal), TimeSpan.FromSeconds(3)); if (local) { Occupy(x, y); return(DateTime.Now.Add(TimeSpan.FromHours(6).Add(TimeSpan.FromMinutes(-20)))); } } // 检测剩余时间 var lastTime = WlyUtilityBiz.GetTime(dmGuid, new WxRect(427, 237, 519, 256), "33ffff-000000"); if (owner) { if (lastTime < TimeSpan.FromMinutes(20)) { // 点击放弃 DMService.Instance.LeftClick(dmGuid, new WxPoint(605, 255)); // 点击确定 DMService.Instance.LeftClick(dmGuid, new WxPoint(452, 330)); return(OccupyPos(x, y)); } // 点击关闭 DMService.Instance.LeftClick(dmGuid, new WxPoint(640, 186)); return(DateTime.Now.Add(lastTime).AddMinutes(-19)); } // 点击关闭 DMService.Instance.LeftClick(dmGuid, new WxPoint(640, 186)); if (lastTime > TimeSpan.FromMinutes(20)) { return(DateTime.Now.Add(lastTime).AddMinutes(-20)); } if (lastTime > TimeSpan.FromMinutes(10)) { return(DateTime.Now.Add(lastTime).AddMinutes(-10)); } // 等待别人的时间到 return(DateTime.Now.Add(lastTime).AddMinutes(1)); } // 占领打开的窗口 void Occupy(int x, int y) { // 点击占领 DMService.Instance.LeftClick(dmGuid, new WxPoint(602, 227), TimeSpan.FromSeconds(2)); // 开启状态 DMService.Instance.LeftClick(dmGuid, new WxPoint(x, y)); // 确认出现天道酬勤 if (!FlowLogicHelper.RepeatRun(() => { Thread.Sleep(500); return(DMService.Instance.FindStr(dmGuid, new WxRect(569, 310, 642, 330), "天道酬勤", WlyColor.Normal)); }, TimeSpan.FromSeconds(3))) { throw new InvalidOperationException("占领失败"); } // 点击天道酬勤 DMService.Instance.LeftClick(dmGuid, new WxPoint(604, 320)); // 点击确定 DMService.Instance.LeftClick(dmGuid, new WxPoint(453, 332)); // 点击加强巡逻 DMService.Instance.LeftClick(dmGuid, new WxPoint(606, 348)); // 点击关闭 DMService.Instance.LeftClick(dmGuid, new WxPoint(640, 186)); } // 占领田1 var nextTime = OccupyPos(600, 300); // 占领田2 var tempTime = OccupyPos(690, 340); if (nextTime > tempTime) { nextTime = tempTime; } // 占领矿1 tempTime = OccupyPos(566, 161); if (nextTime > tempTime) { nextTime = tempTime; } // 占领矿2 tempTime = OccupyPos(724, 208); if (nextTime > tempTime) { nextTime = tempTime; } // 加入下次检测任务 return(new WlyTaskInfo(ID) { NextRunTime = nextTime }); }
/// <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(523, 280, 559, 299), "海战", "e9e7cf-000000")) { DMService.Instance.LeftClick(dmGuid, new WxPoint(500, 331)); return(new WlyTaskInfo(ID, true)); } // 等待活动开始 var startRect = new WxRect(7, 223, 65, 244); var wait = FlowLogicHelper.RepeatRun(() => { Thread.Sleep(400); return(DMService.Instance.FindStr(dmGuid, startRect, "剩余时间", "ffff00-101010")); }, TimeSpan.FromMinutes(1)); if (!wait) { throw new InvalidOperationException("海盗活动未正常开始"); } // 剩余时间 var lastTimeRect = new WxRect(66, 226, 105, 245); // 冷却时间 var coolTimeRect = new WxRect(65, 205, 105, 224); // 得到的分数 var pointRect = new WxRect(972, 94, 994, 113); // 活动结束 var finalRect = new WxRect(488, 416, 522, 438); // 攻击 void Attack() { var fr = DMService.Instance.FindPic(dmGuid, WlyPicType.超强炮舰, WlyUtilityBiz.GameWndRect, out var xx, out var yy); if (fr) { var p = new WxPoint(xx, yy); DMService.Instance.LeftClick(dmGuid, p); } Thread.Sleep(100); // 如果需要金币进行冷却,则确定 var r = new WxRect(436, 342, 472, 365); if (DMService.Instance.FindStr(dmGuid, r, "确定", WlyColor.Normal)) { DMService.Instance.LeftClick(dmGuid, new WxPoint(454, 354)); } } // 活动运行 bool Run() { var lt = WlyUtilityBiz.GetTime(dmGuid, lastTimeRect, "ffffff-000000"); var ct = WlyUtilityBiz.GetTime(dmGuid, coolTimeRect, "ffffff-000000"); // 冷却时间到,开始攻击 if (ct == TimeSpan.Zero) { Attack(); } else { // 计算已经得到的分数,确定是否需要进行强攻 WlyUtilityBiz.GetAmount(dmGuid, pointRect, "ffffff-000000", out var point); var times = point / 33; // 需要在1分30秒之前完成10次攻打 if (lt.Add(TimeSpan.FromSeconds(30 * times)) < TimeSpan.FromMinutes(6).Add(TimeSpan.FromSeconds(30))) { Attack(); } else { // 等待冷却完成 Thread.Sleep(ct.Add(TimeSpan.FromMilliseconds(100))); } } // 检测活动是否结束 if (DMService.Instance.FindStr(dmGuid, finalRect, "确定", WlyColor.Normal)) { DMService.Instance.LeftClick(dmGuid, new WxPoint(505, 430)); return(true); } return(false); } // 开始攻打海盗 FlowLogicHelper.RepeatRun(Run, TimeSpan.FromMinutes(7)); return(new WlyTaskInfo(ID, true)); }