From f25f89101a98ad815c0ae2d25e1a8dc35d53a5dd Mon Sep 17 00:00:00 2001
From: asmrobot <asmrobot@hotmail.com>
Date: Tue, 29 Oct 2019 13:55:37 +0000
Subject: [PATCH] format state machine

---
 src/RichCreator/Maps/Lindong/LindongMap.cs |   76 ++++++++++++++++++--------------------
 1 files changed, 36 insertions(+), 40 deletions(-)

diff --git a/src/RichCreator/Maps/Lindong/LindongMap.cs b/src/RichCreator/Maps/Lindong/LindongMap.cs
index 39ae69b..e8d4e85 100644
--- a/src/RichCreator/Maps/Lindong/LindongMap.cs
+++ b/src/RichCreator/Maps/Lindong/LindongMap.cs
@@ -24,27 +24,27 @@
         /// NextIndex=-1,完成
         /// NextIndex=-2,出错
         /// </summary>
-        internal static MapHouse[] Houses = new MapHouse[] {
-            new MapHouse (){ Index=0 ,NextIndex=1 , OpenStatusDetectIndex=1 , HouseCenterMoveLine=-250,IsEnd=false,DoorDirection=new[]{Direction.Right } },
-            new MapHouse (){ Index=1 ,NextIndex=5 , OpenStatusDetectIndex=5 , HouseCenterMoveLine=-250,IsEnd=false,DoorDirection=new[]{Direction.Bottom } },
-            new MapHouse (){ Index=2 ,NextIndex=1 , OpenStatusDetectIndex=1 , HouseCenterMoveLine=-250,IsEnd=false,DoorDirection=new[]{Direction.Left } },
-            new MapHouse (){ Index=3 ,NextIndex=2 , OpenStatusDetectIndex=2 , HouseCenterMoveLine=-250,IsEnd=false,DoorDirection=new[]{Direction.Left } },
-            new MapHouse (){ Index=4 ,NextIndex=8 , OpenStatusDetectIndex=8 , HouseCenterMoveLine=-250,IsEnd=false,DoorDirection=new[]{Direction.Bottom } },
-            new MapHouse (){ Index=5 ,NextIndex=4 , OpenStatusDetectIndex=4 , HouseCenterMoveLine=-250,IsEnd=false,DoorDirection=new[]{Direction.Left } },
-            new MapHouse (){ Index=6 ,NextIndex=5 , OpenStatusDetectIndex=5 , HouseCenterMoveLine=-250,IsEnd=false,DoorDirection=new[]{Direction.Left } },
-            new MapHouse (){ Index=7 ,NextIndex=6 , OpenStatusDetectIndex=6 , HouseCenterMoveLine=-250,IsEnd=false,DoorDirection=new[]{Direction.Left } },
-            new MapHouse (){ Index=8 ,NextIndex=12 ,OpenStatusDetectIndex=12, HouseCenterMoveLine=-148,IsEnd=false,DoorDirection=new[]{Direction.Right,Direction.Bottom } },
-            new MapHouse (){ Index=9 ,NextIndex=10, OpenStatusDetectIndex=10, HouseCenterMoveLine=-300,IsEnd=false,DoorDirection=new[]{Direction.Right,Direction.Bottom } },
-            new MapHouse (){ Index=10,NextIndex=14, OpenStatusDetectIndex=14, HouseCenterMoveLine=-250,IsEnd=false,DoorDirection=new[]{Direction.Bottom } },
-            new MapHouse (){ Index=11,NextIndex=10, OpenStatusDetectIndex=10, HouseCenterMoveLine=-250,IsEnd=false,DoorDirection=new[]{Direction.Left } },
-            new MapHouse (){ Index=12,NextIndex=13, OpenStatusDetectIndex=12, HouseCenterMoveLine=-220,IsEnd=false,DoorDirection=new[]{Direction.Right } },
-            new MapHouse (){ Index=13,NextIndex=14, OpenStatusDetectIndex=14, HouseCenterMoveLine=-320,IsEnd=false,DoorDirection=new[]{Direction.Right } },
-            new MapHouse (){ Index=14,NextIndex=15, OpenStatusDetectIndex=-1, HouseCenterMoveLine=-320,IsEnd=false,DoorDirection=new[]{Direction.Right } },
-            new MapHouse (){ Index=15,NextIndex=-1, OpenStatusDetectIndex=-1, HouseCenterMoveLine=-250,IsEnd=true, DoorDirection=new[]{Direction.Right } },
-            new MapHouse (){ Index=16,NextIndex=12, OpenStatusDetectIndex=12, HouseCenterMoveLine=-250,IsEnd=false,DoorDirection=new[]{Direction.Up } },
-            new MapHouse (){ Index=17,NextIndex=13, OpenStatusDetectIndex=13, HouseCenterMoveLine=-250,IsEnd=false,DoorDirection=new[]{Direction.Up } },
-            new MapHouse (){ Index=18,NextIndex=14, OpenStatusDetectIndex=14, HouseCenterMoveLine=-250,IsEnd=false,DoorDirection=new[]{Direction.Up } },
-            new MapHouse (){ Index=19,NextIndex=15, OpenStatusDetectIndex=15, HouseCenterMoveLine=-250,IsEnd=false,DoorDirection=new[]{Direction.Up } }
+        internal static HouseInfo[] Houses = new HouseInfo[] {
+            new HouseInfo (){ Index=0 ,NextIndex=1 , OpenStatusDetectIndex=1 , HouseCenterMoveLine=-250,IsEnd=false,DoorDirection=new[]{Direction.Right } },
+            new HouseInfo (){ Index=1 ,NextIndex=5 , OpenStatusDetectIndex=5 , HouseCenterMoveLine=-250,IsEnd=false,DoorDirection=new[]{Direction.Bottom } },
+            new HouseInfo (){ Index=2 ,NextIndex=1 , OpenStatusDetectIndex=1 , HouseCenterMoveLine=-250,IsEnd=false,DoorDirection=new[]{Direction.Left } },
+            new HouseInfo (){ Index=3 ,NextIndex=2 , OpenStatusDetectIndex=2 , HouseCenterMoveLine=-250,IsEnd=false,DoorDirection=new[]{Direction.Left } },
+            new HouseInfo (){ Index=4 ,NextIndex=8 , OpenStatusDetectIndex=8 , HouseCenterMoveLine=-250,IsEnd=false,DoorDirection=new[]{Direction.Bottom } },
+            new HouseInfo (){ Index=5 ,NextIndex=4 , OpenStatusDetectIndex=4 , HouseCenterMoveLine=-250,IsEnd=false,DoorDirection=new[]{Direction.Left } },
+            new HouseInfo (){ Index=6 ,NextIndex=5 , OpenStatusDetectIndex=5 , HouseCenterMoveLine=-250,IsEnd=false,DoorDirection=new[]{Direction.Left } },
+            new HouseInfo (){ Index=7 ,NextIndex=6 , OpenStatusDetectIndex=6 , HouseCenterMoveLine=-250,IsEnd=false,DoorDirection=new[]{Direction.Left } },
+            new HouseInfo (){ Index=8 ,NextIndex=12 ,OpenStatusDetectIndex=12, HouseCenterMoveLine=-148,IsEnd=false,DoorDirection=new[]{Direction.Right,Direction.Bottom } },
+            new HouseInfo (){ Index=9 ,NextIndex=10, OpenStatusDetectIndex=10, HouseCenterMoveLine=-300,IsEnd=false,DoorDirection=new[]{Direction.Right,Direction.Bottom } },
+            new HouseInfo (){ Index=10,NextIndex=14, OpenStatusDetectIndex=14, HouseCenterMoveLine=-250,IsEnd=false,DoorDirection=new[]{Direction.Bottom } },
+            new HouseInfo (){ Index=11,NextIndex=10, OpenStatusDetectIndex=10, HouseCenterMoveLine=-250,IsEnd=false,DoorDirection=new[]{Direction.Left } },
+            new HouseInfo (){ Index=12,NextIndex=13, OpenStatusDetectIndex=12, HouseCenterMoveLine=-220,IsEnd=false,DoorDirection=new[]{Direction.Right } },
+            new HouseInfo (){ Index=13,NextIndex=14, OpenStatusDetectIndex=14, HouseCenterMoveLine=-320,IsEnd=false,DoorDirection=new[]{Direction.Right } },
+            new HouseInfo (){ Index=14,NextIndex=15, OpenStatusDetectIndex=-1, HouseCenterMoveLine=-320,IsEnd=false,DoorDirection=new[]{Direction.Right } },
+            new HouseInfo (){ Index=15,NextIndex=-1, OpenStatusDetectIndex=-1, HouseCenterMoveLine=-250,IsEnd=true, DoorDirection=new[]{Direction.Right } },
+            new HouseInfo (){ Index=16,NextIndex=12, OpenStatusDetectIndex=12, HouseCenterMoveLine=-250,IsEnd=false,DoorDirection=new[]{Direction.Up } },
+            new HouseInfo (){ Index=17,NextIndex=13, OpenStatusDetectIndex=13, HouseCenterMoveLine=-250,IsEnd=false,DoorDirection=new[]{Direction.Up } },
+            new HouseInfo (){ Index=18,NextIndex=14, OpenStatusDetectIndex=14, HouseCenterMoveLine=-250,IsEnd=false,DoorDirection=new[]{Direction.Up } },
+            new HouseInfo (){ Index=19,NextIndex=15, OpenStatusDetectIndex=15, HouseCenterMoveLine=-250,IsEnd=false,DoorDirection=new[]{Direction.Up } }
         };
 
         static LindongMap()
@@ -172,10 +172,10 @@
         /// <summary>
         /// 小地图区域
         /// </summary>
-        public ZTPoint MinimapPoint = ZTPoint.Empty;
+        public Utility.Structs.ZTPoint MinimapPoint = Utility.Structs.ZTPoint.Empty;
 
         //小地图距游戏区域的偏移
-        private ZTPoint minimapPointOffset = new ZTPoint(1201, 47);
+        private Utility.Structs.ZTPoint minimapPointOffset = new Utility.Structs.ZTPoint(1201, 47);
 
         public CancellationToken cancellationToken { get; set; }
 
@@ -269,7 +269,7 @@
         private void ExitToTown()
         {
             G.Instance.DebugWriter("返回城镇");
-            ZTPoint point = new ZTPoint(this.GameRect.End.X - 124, this.GameRect.Start.Y + 146);
+            Utility.Structs.ZTPoint point = new Utility.Structs.ZTPoint(this.GameRect.End.X - 124, this.GameRect.Start.Y + 146);
             G.Instance.InputControl.MoveToAndClick(point);
             Thread.Sleep(5000);
         }
@@ -280,7 +280,7 @@
         private void ReplayGame()
         {
             G.Instance.DebugWriter("重新挑战");
-            ZTPoint point = new ZTPoint(this.GameRect.End.X - 132, this.GameRect.Start.Y + 90);
+            Utility.Structs.ZTPoint point = new Utility.Structs.ZTPoint(this.GameRect.End.X - 132, this.GameRect.Start.Y + 90);
             G.Instance.InputControl.MoveToAndClick(point);
         }
 
@@ -335,8 +335,8 @@
                 
 
                 DateTime roomStartTime = DateTime.Now;
-                KillMonsterStateMachine kmsm = new KillMonsterStateMachine(Houses[houseIndex], this.MinimapPoint, this.GameRect, preHouseIndex,this.runningStep);
-                ZTResult smresult = kmsm.Work(cancellationToken, 5 * 60 * 1000);
+                KillMonsterStateMachine kmsm = new KillMonsterStateMachine(Houses[houseIndex], this.MinimapPoint, this.GameRect, preHouseIndex,this.runningStep, cancellationToken);
+                ZTResult smresult = kmsm.Work( 5 * 60 * 1000);
                 Int32 roomTotalSecond = (Int32)(DateTime.Now - roomStartTime).TotalSeconds;
                 G.Instance.InfoWriter("房间刷完,用时:" + (roomTotalSecond / 60) + "分" + (roomTotalSecond % 60) + "秒");
                 runningStep = RunningStep.None;
@@ -367,7 +367,7 @@
             bool result = FuncUtils.NoChangeRetryCallWrap(
                () =>
                {
-
+                   WindowUtils.SetDnfToTop();
                    CloseAllAlertWindow(this.cancellationToken, this.GameRect);
                    //向下走出赛丽亚的房间  ,走向素喃
                    G.Instance.InputControl.PressKey(2000, HIDCode.DownArrow);
@@ -400,15 +400,15 @@
         /// <returns></returns>
         private bool MoveToShikongzhimen()
         {
-            bool result=FuncUtils.NoChangeRetryCallWrap(() =>
+            bool result= FuncUtils.NoChangeRetryCallWrap(() =>
             {
                 //打开地图
-                ZTPoint mapButtonPosition = new ZTPoint(this.GameRect.End.X - 14, this.GameRect.Start.Y + 16);
+                Utility.Structs.ZTPoint mapButtonPosition = new Utility.Structs.ZTPoint(this.GameRect.End.X - 14, this.GameRect.Start.Y + 16);
                 G.Instance.InputControl.MoveToAndClick(mapButtonPosition);
                 Thread.Sleep(1000);
-                
+
                 //点到副本之前的地图
-                ZTPoint mapPrePosition = new ZTPoint(this.GameRect.Start.X + 382, this.GameRect.Start.Y + 252);
+                Utility.Structs.ZTPoint mapPrePosition = new Utility.Structs.ZTPoint(this.GameRect.Start.X + 382, this.GameRect.Start.Y + 252);
                 G.Instance.InputControl.MoveToAndClick(mapPrePosition);
 
                 //关闭地图框
@@ -539,7 +539,7 @@
                 return true; 
             }
 
-            G.Instance.InputControl.MoveToAndClick(new ZTPoint(this.GameRect.Start.X + 508, this.GameRect.Start.Y + 552));
+            G.Instance.InputControl.MoveToAndClick(new Utility.Structs.ZTPoint(this.GameRect.Start.X + 508, this.GameRect.Start.Y + 552));
             Thread.Sleep(5000);
             image = ScreenCapture.Instance.CaptureScreenReturnImage();
             if (LindongCVHelper.GetChoiceLingdongNandu(out nandu, image, this.GameRect))
@@ -624,7 +624,6 @@
 
             if (!result)
             {
-                //todo:remove
                 G.Instance.InfoWriter("装备文字未取到");
                 return false;
             }
@@ -632,7 +631,7 @@
 
 
             //开始点,每格步进30
-            ZTPoint startPoint = new ZTPoint( equipmentTextRect.End.X-30,equipmentTextRect.End.Y+9);
+            Utility.Structs.ZTPoint startPoint = new Utility.Structs.ZTPoint( equipmentTextRect.End.X-30, equipmentTextRect.End.Y+9);
             List<Int32> points = DnfCVHelper.GetEquipmentIndexs(startPoint);
 
             for (int i = 0; i < points.Count; i++)
@@ -643,9 +642,9 @@
                 int col = index % 8;
                 int x = col * 30+15;
                 int y = row * 30+15;
-                
+
                 //点窗格
-                G.Instance.InputControl.MoveToAndClick(new ZTPoint(startPoint.X+x,startPoint.Y+y));
+                G.Instance.InputControl.MoveToAndClick(new Utility.Structs.ZTPoint(startPoint.X + x, startPoint.Y + y));
                 Thread.Sleep(500);
                 //点确定
                 G.Instance.InputControl.Move(0, 0, true, false, false);
@@ -658,8 +657,5 @@
             G.Instance.InputControl.PressKey(RandomUtils.KeyPressDuration, HIDCode.Escape);
             return true;
         }
-
-
-
     }
 }

--
Gitblit v1.9.3