asmrobot
2019-11-21 589ed88a5924a7494e21b95b6bbff5e46ff49ddd
src/RichCreator/StateMachines/ChannelStateMachine.cs
@@ -1,9 +1,11 @@
using Emgu.CV;
using Emgu.CV.Structure;
using RichCreator.Maps;
using RichCreator.Utility;
using RichCreator.Utility.Captures;
using RichCreator.Utility.CV;
using RichCreator.Utility.Structs;
using RichCreator.Utilitys;
using System;
using System.Collections.Generic;
using System.Linq;
@@ -31,8 +33,8 @@
        
        //频道距离“频道选择文字”的偏移
        private static ZTPoint[] channelOffsets = new ZTPoint[] {
                new ZTPoint(-279,246),
                new ZTPoint(-279,291)
                new ZTPoint(-270,252),
                new ZTPoint(-270,293)
            };
        //首次进入标记
@@ -103,7 +105,7 @@
                        break;
                    case ChannelStates.CloseAllWindow1:
                        //关闭所有窗口1
                        CloseAllAlertWindow(cancelToken, gameRect);
                        GameUtils.CloseAllAlertWindowByX(cancelToken, gameRect);
                        currentState = ChannelStates.CheckGroupMode;
                        break;
                    case ChannelStates.IsChoiceRolePage:
@@ -188,13 +190,13 @@
                        break;
                    case ChannelStates.OpenChangeChannelPage:
                        //打开切换频道界面
                        G.Instance.InputControl.MoveToAndClick(new ZTPoint(gameRect.End.X - 136, gameRect.Start.Y + 9));
                        G.Instance.InputControl.MoveToAndClick(new ZTPoint(gameRect.Start.X +690, gameRect.Start.Y + 11));
                        Thread.Sleep(2000);
                        currentState = ChannelStates.ChangeChannelPageIsOpen;
                        break;
                    case ChannelStates.CloseAllWindow:
                        //关闭所有窗口
                        CloseAllAlertWindow(cancelToken,gameRect);
                        GameUtils.CloseAllAlertWindowByX(cancelToken,gameRect);
                        currentState = ChannelStates.Complete;
                        break;
                    default:
@@ -204,38 +206,7 @@
            return ZTResult.Success;
        }
        /// <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))
                {
                    return true;
                }
                G.Instance.InputControl.MoveToAndClick(closeButtonRect.GetCenterPoint());
                Thread.Sleep(500);
            }
            return false;
        }
        /// <summary>
        /// 频道状态
        /// </summary>