asmrobot
2019-11-25 2aeab450471cb80b59002da7da80faf251a0c4f4
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
using Emgu.CV;
using Emgu.CV.Structure;
using RichCreator.Dnf;
using RichCreator.Utility;
using RichCreator.Utility.Captures;
using RichCreator.Utility.CV;
using RichCreator.Utility.InputControl;
using RichCreator.Utility.Maps;
using RichCreator.Utility.Structs;
using RichCreator.Utility.Utilitys;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
 
namespace RichCreator.Maps
{
    public abstract class ShikongzhimenMapBase:MapInfo
    {
        public ShikongzhimenMapBase(MapType mapType, ZTRectangle gameRect, CancellationToken cancellationToken):base(mapType,gameRect,cancellationToken)
        { }
        /// <summary>
        /// 步行到素喃
        /// </summary>
        /// <returns></returns>
        protected bool MoveToSunan()
        {
            bool result = FuncUtils.NoChangeRetryCallWrap(
               () =>
               {
                   WindowUtils.SetDnfToTop();
                   CloseAllAlertWindowByX(this.CancelToken, this.GameRect);
                   //向下走出赛丽亚的房间  ,走向素喃
                   G.Instance.InputControl.PressKey(2000, HIDCode.DownArrow);
                   return true;
               },
               () =>
               {
                   G.Instance.InfoWriter("检测是否进入素喃");
                   result = FuncUtils.TimeoutCancelableWrap(10000, this.CancelToken, () => {
                       return ShikongzhimenCVHelper.IsInSunan(this.GameRect);
                   });
                   if (!result)
                   {
                       G.Instance.InfoWriter("进入素喃失败");
                       return false;
                   }
 
                   G.Instance.InfoWriter("进入素喃成功");
                   return true;
               },
               () =>
               {
                   return DnfCVHelper.IsInSaiLiYaHouse(this.GameRect);
               });
            return result;
        }
 
        /// <summary>
        /// 步行至时空之门
        /// </summary>
        /// <returns></returns>
        protected bool MoveToShikongzhimen()
        {
            bool result = FuncUtils.NoChangeRetryCallWrap(() =>
            {
                //打开地图
                Utility.Structs.ZTPoint mapButtonPosition = new Utility.Structs.ZTPoint(this.GameRect.Start.X + 782, this.GameRect.Start.Y + 16);
                G.Instance.InputControl.MoveToAndClick(mapButtonPosition);
                Thread.Sleep(1000);
 
                //点到副本之前的地图
                Utility.Structs.ZTPoint mapPrePosition = new Utility.Structs.ZTPoint(this.GameRect.Start.X + 143, this.GameRect.Start.Y + 197);
                G.Instance.InputControl.MoveToAndClick(mapPrePosition);
                Thread.Sleep(1000);
 
                //关闭地图框
                CloseAllAlertWindowByEsc(this.CancelToken, this.GameRect);
                return true;
            },
            () =>
            {
                //检测是否进入时空之门
                return FuncUtils.TimeoutCancelableWrap(15000, this.CancelToken, () =>
                {
                    CloseAllAlertWindowByX(this.CancelToken, this.GameRect);
                    return ShikongzhimenCVHelper.IsInShikongzhimen(this.GameRect);
                });
            },
            () =>
            {
                //检测是否还在素喃
                return FuncUtils.TimeoutCancelableWrap(3000, this.CancelToken, () => {
                    CloseAllAlertWindowByX(this.CancelToken, this.GameRect);
                    return ShikongzhimenCVHelper.IsInSunan(this.GameRect);
                });
            });
 
            Thread.Sleep(5000);
            return result;
        }
 
        /// <summary>
        /// 步行到任务选择和正式开打页面
        /// </summary>
        /// <returns></returns>
        protected bool MoveToChoiceTaskPage()
        {
            bool result = false;
            //右走进选择副本界面
            G.Instance.InputControl.PressKey(1500, HIDCode.LeftArrow);
 
 
            G.Instance.InfoWriter("检测是否打开选择副本界面");
            result = FuncUtils.TimeoutCancelableWrap(10000, this.CancelToken, () => {
                Image<Rgb, byte> image = ScreenCapture.Instance.CaptureScreenReturnImage();
                return ShikongzhimenCVHelper.IsInChoiceTaskPage(image, this.GameRect);
            });
            if (!result)
            {
                G.Instance.InfoWriter("进入打开选择副本界面失败");
                return false;
            }
            G.Instance.InfoWriter("打开选择副本界面成功");
            return true;
        }
    }
}