From 589ed88a5924a7494e21b95b6bbff5e46ff49ddd Mon Sep 17 00:00:00 2001
From: asmrobot <asmrobot@hotmail.com>
Date: Thu, 21 Nov 2019 01:08:42 +0000
Subject: [PATCH] kalete map
---
src/RichCreator/Jobs/DNFJob.cs | 223 ++++++++++++++++++++++++++++++++++++++++++-------------
1 files changed, 171 insertions(+), 52 deletions(-)
diff --git a/src/RichCreator/Jobs/DNFJob.cs b/src/RichCreator/Jobs/DNFJob.cs
index b428ae8..dc50bcf 100644
--- a/src/RichCreator/Jobs/DNFJob.cs
+++ b/src/RichCreator/Jobs/DNFJob.cs
@@ -32,27 +32,7 @@
{
this.MapType = mapType;
}
-
-
- /// <summary>
- /// 选角色时的角色选择偏移
- /// </summary>
- private static ZTPoint[] RoleOffset = new Utility.Structs.ZTPoint[] {
- new ZTPoint (154,225),
- new ZTPoint (300,225),
- new ZTPoint (443,225),
- new ZTPoint (593,225),
- new ZTPoint (726,225),
- new ZTPoint (883,225),
-
- new ZTPoint (154,455),
- new ZTPoint (300,455),
- new ZTPoint (443,455),
- new ZTPoint (593,455),
- new ZTPoint (726,455),
- new ZTPoint (883,455)
- };
-
+
/// <summary>
/// 游戏窗口
/// </summary>
@@ -207,12 +187,16 @@
() =>
{
WindowUtils.SetDnfToTop();
- //选角色
- G.Instance.InputControl.MoveToAndClick(this.GameRect.Start.Add(RoleOffset[roleIndex]));
- Thread.Sleep(500);
- //点进入游戏
- G.Instance.InputControl.MoveToAndClick(startGameButtonRect.GetCenterPoint());
+ if (SelectRoleIndex(roleIndex))
+ {
+ //点进入游戏
+ G.Instance.InputControl.MoveToAndClick(startGameButtonRect.GetCenterPoint());
+ return true;
+ }
+ Thread.Sleep(1000);
+ return false;
+
},
() =>
{
@@ -228,38 +212,176 @@
return true;
}
return false;
- });
+ },3);
return result;
}
- /// <summary>
- /// 关闭所有弹出窗
- /// </summary>
- /// <param name="cancelToken"></param>
- /// <param name="gameRect"></param>
- /// <returns></returns>
- private bool CloseAllAlertWindow(CancellationToken cancelToken, ZTRectangle gameRect)
- {
- while (!cancelToken.IsCancellationRequested)
- {
- G.Instance.InputControl.MoveTo(0, 0, false, false, false);
- Thread.Sleep(10);
- //截图
- System.Drawing.Bitmap bitmap = ScreenCapture.Instance.CaptureScreen();
- Image<Rgb, byte> image = new Image<Rgb, byte>(bitmap);
- ZTRectangle closeButtonRect = ZTRectangle.Empty;
- if (!DnfCVHelper.GetAlertWindow(out closeButtonRect, image, gameRect))
+
+ /// <summary>
+ /// 选角色时的角色选择偏移
+ /// </summary>
+ private static ZTPoint[] RoleOffset = new Utility.Structs.ZTPoint[] {
+ new ZTPoint (133,191),
+ new ZTPoint (249,191),
+ new ZTPoint (371,191),
+ new ZTPoint (499,191),
+
+
+ new ZTPoint (133,398),
+ new ZTPoint (249,398),
+ new ZTPoint (371,398),
+ new ZTPoint (499,398),
+
+ new ZTPoint (133,398),
+ new ZTPoint (249,398)
+ };
+
+
+ /// <summary>
+ /// 选择角色
+ /// </summary>
+ /// <param name="roleIndex"></param>
+ /// <returns></returns>
+ private bool SelectRoleIndex(Int32 roleIndex)
+ {
+ if (roleIndex < 8)
+ {
+ //移到顶端
+ if (!ScrollMoveToTop())
+ {
+ return false;
+ }
+
+ }
+ else
+ {
+ //移到顶端,向下一格
+ if (!ScrollMoveToDownOne())
+ {
+ return false;
+ }
+ }
+
+ Thread.Sleep(1000);
+ //选角色
+ G.Instance.InputControl.MoveToAndClick(this.GameRect.Start.Add(RoleOffset[roleIndex]));
+ Thread.Sleep(500);
+ return true;
+ }
+
+ /// <summary>
+ /// 滚动条移动到顶端
+ /// </summary>
+ /// <returns></returns>
+ private bool ScrollMoveToTop()
+ {
+ ZTRectangle upButton = ZTRectangle.Empty;
+ ZTRectangle downButton = ZTRectangle.Empty;
+ ZTRectangle scrollButton = ZTRectangle.Empty;
+
+
+ //查找滚动条位置
+ if (DnfCVHelper.FindSelectRoleScroll(out upButton, out downButton, out scrollButton, this.GameRect))
+ {
+ //是在顶部
+ if (Math.Abs(upButton.End.Y - scrollButton.Start.Y) < 3)
+ {
+ return true;
+ }
+ }
+
+
+
+ Int32 counter = 4;
+ while(counter>0)
+ {
+ counter--;
+ //查找滚动条位置
+ if (!DnfCVHelper.FindSelectRoleScroll(out upButton, out downButton, out scrollButton, this.GameRect))
+ {
+ continue;
+ }
+
+ //是在顶部
+ if (Math.Abs(upButton.End.Y - scrollButton.Start.Y) < 3)
{
return true;
}
- G.Instance.InputControl.MoveToAndClick(closeButtonRect.GetCenterPoint());
- Thread.Sleep(500);
+ ZTPoint targetPoint = scrollButton.GetCenterPoint();
+ G.Instance.InputControl.MoveTo(targetPoint.X, targetPoint.Y, false, false, false);
+ G.Instance.InputControl.Move(0, 0, true, false, false);
+ targetPoint = upButton.GetCenterPoint();
+ G.Instance.InputControl.MoveTo(targetPoint.X, targetPoint.Y, true, false, false);
+ G.Instance.InputControl.Move(0, 0, false, false, false);
+ Thread.Sleep(RandomUtils.KeyPressDuration);
+ G.Instance.InputControl.MoveTo(this.GameRect.End.X, this.GameRect.Start.Y, false, false, false);
+ Thread.Sleep(RandomUtils.KeyPressDuration);
}
+
return false;
}
+
+ /// <summary>
+ /// 滚动条移动到下一格
+ /// </summary>
+ /// <returns></returns>
+ private bool ScrollMoveToDownOne()
+ {
+ ZTRectangle upButton = ZTRectangle.Empty;
+ ZTRectangle downButton = ZTRectangle.Empty;
+ ZTRectangle scrollButton = ZTRectangle.Empty;
+
+
+ //查找滚动条位置
+ if (DnfCVHelper.FindSelectRoleScroll(out upButton, out downButton, out scrollButton, this.GameRect))
+ {
+ //是在下一格
+ if (Math.Abs(upButton.End.Y - scrollButton.Start.Y) > 3&& Math.Abs(upButton.End.Y - scrollButton.Start.Y)<30)
+ {
+ return true;
+ }
+ }
+
+
+
+ Int32 counter = 4;
+ while (counter > 0)
+ {
+ counter--;
+ //查找滚动条位置
+ if (!DnfCVHelper.FindSelectRoleScroll(out upButton, out downButton, out scrollButton, this.GameRect))
+ {
+ continue;
+ }
+
+ //是在第一格
+ if (Math.Abs(upButton.End.Y - scrollButton.Start.Y) > 3 && Math.Abs(upButton.End.Y - scrollButton.Start.Y) < 30)
+ {
+ return true;
+ }
+
+ ZTPoint targetPoint = scrollButton.GetCenterPoint();
+ G.Instance.InputControl.MoveTo(targetPoint.X, targetPoint.Y, false, false, false);
+ G.Instance.InputControl.Move(0, 0, true, false, false);
+ targetPoint = upButton.GetCenterPoint();
+ G.Instance.InputControl.MoveTo(targetPoint.X, targetPoint.Y, true, false, false);
+ G.Instance.InputControl.Move(0, 0, false, false, false);
+ Thread.Sleep(RandomUtils.KeyPressDuration);
+
+
+ G.Instance.InputControl.MoveToAndClick(downButton.GetCenterPoint());
+ Thread.Sleep(RandomUtils.KeyPressDuration);
+ G.Instance.InputControl.MoveTo(this.GameRect.End.X, this.GameRect.Start.Y, false, false, false);
+ Thread.Sleep(RandomUtils.KeyPressDuration);
+ }
+
+
+ return false;
+ }
+
/// <summary>
/// 返回选择角色界面
@@ -291,17 +413,14 @@
if (result)
{
- //点击切换角色按钮624,502
- G.Instance.InputControl.MoveToAndClick(new Utility.Structs.ZTPoint(this.GameRect.Start.X + 624, this.GameRect.Start.Y + 502));
+ //点击切换角色按钮388,445
+ G.Instance.InputControl.MoveToAndClick(new Utility.Structs.ZTPoint(this.GameRect.Start.X + 388, this.GameRect.Start.Y + 445));
return true;
}
G.Instance.InfoWriter("退回选择角色界面失败");
return false;
}
-
-
-
-
+
/// <summary>
/// 根据当前选择的地图实例化DNF地图
/// </summary>
--
Gitblit v1.9.3