asmrobot
2019-11-13 576b92fd82f568572bc4beb125fa0ba0191a602f
src/RichCreator/Maps/Test/TestMap.cs
@@ -13,29 +13,25 @@
using System.Threading;
using static RichCreator.Utility.CV.GroupCVHelper;
using RichCreator.StateMachines;
using RichCreator.Utility.Maps;
using RichCreator.Dnf;
namespace RichCreator.Maps
namespace RichCreator.Maps.Test
{
    /// <summary>
    /// 测试地图
    /// </summary>
    public class TestMap : MapInfo
    {
        /// <summary>
        /// 游戏区域
        /// </summary>
        public ZTRectangle GameRect { get; set; }
        public TestMap(ZTRectangle gameRect, CancellationToken cancelToken) :base(MapType.Test, gameRect, cancelToken)
        {
        public CancellationToken cancellationToken { get; set; }
        }
        private const bool isCreateGroup = true;
        
        public override ZTResult Start(ZTRectangle gameRect, CancellationToken cancelToken, Int32 runningStep)
        {
            this.GameRect = gameRect;
            this.cancellationToken = cancelToken;
            WindowUtils.SetDnfToTop();
        public override ZTResult Start(Int32 runningStep)
        {WindowUtils.SetDnfToTop();
            
           
@@ -61,7 +57,7 @@
            }
            //沉默一段时间
            Thread.Sleep(50000000);
            CloseAllAlertWindow(this.cancellationToken, this.GameRect);
            CloseAllAlertWindow(this.CancelToken, this.GameRect);
            return ZTResult.Success;
        }
        
@@ -111,7 +107,7 @@
            //点击创建
            G.Instance.InputControl.MoveToAndClick(okButtonRect.GetCenterPoint());
            
            bool result = FuncUtils.TimeoutCancelableWrap(5000, this.cancellationToken, () => {
            bool result = FuncUtils.TimeoutCancelableWrap(5000, this.CancelToken, () => {
                //识别是否有我的队伍按钮
                return GroupCVHelper.ExistsMyGroupButton(out mygroupButtonRect, this.GameRect);
            });
@@ -119,7 +115,7 @@
            {
                G.Instance.InfoWriter("create group ok");
                //点击组队“确定”按钮
                result = FuncUtils.TimeoutCancelableWrap(15 * 60 * 1000,this.cancellationToken, () => {
                result = FuncUtils.TimeoutCancelableWrap(15 * 60 * 1000,this.CancelToken, () => {
                    Utility.Structs.ZTPoint yes = Utility.Structs.ZTPoint.Empty;
                    Utility.Structs.ZTPoint no = Utility.Structs.ZTPoint.Empty;
                    bool retFind = GroupCVHelper.FindYaoqingZuduiWindow(out yes, out no, this.GameRect);
@@ -161,7 +157,7 @@
                return true;
            }
            Utility.Structs.ZTPoint searchButtonCenerPoint = searchButtonRect.GetCenterPoint();
            ZTPoint searchButtonCenerPoint = searchButtonRect.GetCenterPoint();
            //输入组名
            G.Instance.InputControl.MoveToAndClick(new Utility.Structs.ZTPoint (searchButtonCenerPoint.X-80, searchButtonCenerPoint.Y));
            DeleteAllChar(groupName.Length + 3);
@@ -173,7 +169,7 @@
            //查找组项
            ZTRectangle groupItemRect = ZTRectangle.Empty;
            bool result = FuncUtils.TimeoutCancelableWrap(5000, this.cancellationToken, () => {
            bool result = FuncUtils.TimeoutCancelableWrap(5000, this.CancelToken, () => {
                //识别组项
                return GroupCVHelper.FindGroupItem(out groupItemRect, this.GameRect);
            });
@@ -189,7 +185,7 @@
            //查找是否打开成员列表窗
            ZTRectangle joinButtonRect = ZTRectangle.Empty;
            result = FuncUtils.TimeoutCancelableWrap(5000, this.cancellationToken, () => {
            result = FuncUtils.TimeoutCancelableWrap(5000, this.CancelToken, () => {
                //识别是否打开成员列表窗
                return GroupCVHelper.FindGroupMemberWindow(out joinButtonRect, this.GameRect);
            });
@@ -203,7 +199,7 @@
            G.Instance.InputControl.MoveToAndClick(joinButtonRect.GetCenterPoint());
            //查找是否已经组队成功,30秒
            result = FuncUtils.TimeoutCancelableWrap(30000, this.cancellationToken, () => {
            result = FuncUtils.TimeoutCancelableWrap(30000, this.CancelToken, () => {
                //识别是否有我的队伍按钮
                return GroupCVHelper.ExistsMyGroupButton(out mygroupButtonRect, this.GameRect);
            });
@@ -237,10 +233,10 @@
            ZTRectangle innerGroupWindowTextRect = ZTRectangle.Empty, innerSearchButtonRect = ZTRectangle.Empty, innerCreateGroupButton = ZTRectangle.Empty;
            for (int i = 0; i < 2; i++)
            {
                CloseAllAlertWindow(this.cancellationToken, this.GameRect);
                CloseAllAlertWindow(this.CancelToken, this.GameRect);
                G.Instance.InputControl.PressKey(RandomUtils.KeyPressDuration, HIDCode.RightSquarebrackets);
                bool result = FuncUtils.TimeoutCancelableWrap(5000, this.cancellationToken, () => {
                bool result = FuncUtils.TimeoutCancelableWrap(5000, this.CancelToken, () => {
                    //识别队伍窗
                    return GroupCVHelper.FindGroupWindow(out innerGroupWindowTextRect, out innerSearchButtonRect, out innerCreateGroupButton,out innerHasGroup, this.GameRect);
                });
@@ -285,7 +281,7 @@
            {
                //点击创建队伍
                G.Instance.InputControl.MoveToAndClick(createGroupButtonRect.GetCenterPoint());
                bool result = FuncUtils.TimeoutCancelableWrap(5000, this.cancellationToken, () => {
                bool result = FuncUtils.TimeoutCancelableWrap(5000, this.CancelToken, () => {
                    //识别创建队伍窗
                    return GroupCVHelper.FindCreateGroupWindow(out innerCreateGroupWindowTextRect, out innerOkButtonRect, this.GameRect);
                });