| | |
| | | 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; |
| | |
| | | /// <summary> |
| | | /// 频道状态机 |
| | | /// </summary> |
| | | public class ChannelStateMachine |
| | | public class ChannelStateMachine:StateMachineBase |
| | | { |
| | | //默认状态 |
| | | private ChannelStates currentState = ChannelStates.Start; |
| | |
| | | |
| | | //频道距离“频道选择文字”的偏移 |
| | | private static ZTPoint[] channelOffsets = new ZTPoint[] { |
| | | new ZTPoint(-279,246), |
| | | new ZTPoint(-279,291) |
| | | new ZTPoint(-270,252), |
| | | new ZTPoint(-270,293) |
| | | }; |
| | | |
| | | //首次进入标记 |
| | | private bool FirstEntryHouse = true; |
| | | |
| | | /// <summary> |
| | | /// 开始工作 |
| | |
| | | if (DnfCVHelper.IsInSaiLiYaHouse(gameRect)) |
| | | { |
| | | //检测是否组队模式 |
| | | currentState = ChannelStates.CheckGroupMode; |
| | | currentState = ChannelStates.IsFirstEntry; |
| | | } |
| | | else |
| | | { |
| | | currentState = ChannelStates.IsChoiceRolePage; |
| | | } |
| | | break; |
| | | case ChannelStates.IsFirstEntry: |
| | | //是否初次进入 |
| | | if (this.FirstEntryHouse) |
| | | { |
| | | this.FirstEntryHouse = false; |
| | | currentState = ChannelStates.CloseAllWindow1; |
| | | } |
| | | else |
| | | { |
| | | currentState = ChannelStates.CheckGroupMode; |
| | | } |
| | | break; |
| | | case ChannelStates.CloseAllWindow1: |
| | | //关闭所有窗口1 |
| | | GameUtils.CloseAllAlertWindowByX(cancelToken, gameRect); |
| | | currentState = ChannelStates.CheckGroupMode; |
| | | break; |
| | | case ChannelStates.IsChoiceRolePage: |
| | | //检测是否角色选择界面 |
| | |
| | | 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: |
| | |
| | | |
| | | 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> |
| | |
| | | ChangeChannel,//双击切换频道,等待两秒 |
| | | OpenChangeChannelPage,//打开切换频道界面 |
| | | CloseAllWindow,//关闭所有窗口 |
| | | IsFirstEntry,//是否首次进入赛丽亚的房间 |
| | | CloseAllWindow1,//关闭所有窗口1 |
| | | Complete//完成 |
| | | } |
| | | } |