/// <summary> /// 鼠标点击指令 /// </summary> /// <param name="GameHandle"></param> /// <param name="xy"></param> /// <param name="delayTime"></param> /// <param name="OffsetX"></param> /// <param name="OffsetY"></param> /// <returns></returns> public static Point Click(GameHandleClass GameHandle, Point xy, int delayTime, int OffsetX = 0, int OffsetY = 0) { try { GlobalObject.GetUIForm().ChangeClickCoordinate($"{xy.X},{xy.Y}", 2); if (!GameHandle.IsSuccess) { throw new Exceptions.NoGameHandleException(); } Delay(delayTime + 50); //延迟 var OffsetXY = new Point(OffsetX, OffsetY); //序列坐标偏移 OffsetXY.Offset(GlobalObject.ClickOffsetXY); // 游戏窗口偏移坐标(poi)// //手动坐标偏移 xy.Offset(OffsetXY); PreviousXY = xy;//记录本次点击坐标 Delay(Random(100, 300)); if (GameHandle.Mode == FunctionHandle.MODE.Handle) { ClickInHandle(GameHandle, xy, OffsetXY); } else if (GameHandle.Mode == FunctionHandle.MODE.Desktop) { ClickInScreen(xy, GameHandle.XY); } else if (GameHandle.Mode == FunctionHandle.MODE.Chorme) { xy.Offset(GameHandle.XY); OffsetXY.Offset(GameHandle.XY); ClickInHandle(GameHandle, xy, OffsetXY); } else { throw new Exceptions.DataErrorException("无法识别正确的游戏取色模式!"); } Delay(Random(200, 400)); return(PreviousXY); } finally { GlobalObject.GetUIForm().ChangeClickCoordinate($"{xy.X},{xy.Y}", 1); } }
/// <summary> /// 判断给定数据和图像中的颜色数据是否一样(相似) /// </summary> /// <param name="bmp">需要判断的游戏图像</param> /// <param name="data">需要判定的数据</param> /// <param name="rin">容许色差阈值(0~441)</param> /// <param name="OffsetX">X坐标偏移</param> /// <param name="OffsetY">Y坐标偏移</param> /// <returns></returns> private static bool Judge(Bitmap bmp, DataJudge data, int rin = 0, int OffsetX = 0, int OffsetY = 0) { lock (_locked) { // 更改ui控件显示 GlobalObject.GetUIForm().ChangeJudgeCoordinate(data.XYToStr, 2); Delay(Random(2, 10)); try { DataJudge DecisionData = new DataJudge($"{(data.XY.X + OffsetX).ToString()},{(data.XY.Y + OffsetY).ToString()} @ {FunctionBitmap.GetColorData(bmp, $"{(data.XY.X + OffsetX).ToString()},{(data.XY.Y + OffsetY).ToString()}", data.Width, data.Height)}", "取得数据-" + data.Name); if (!DecisionData.ColorCollection.IsExist()) { throw new Exceptions.DataErrorException("从图像中提取的颜色集合数据错误!"); } else if ((DecisionData.ColorCollection.X != data.ColorCollection.X) || (DecisionData.ColorCollection.Y != data.ColorCollection.Y)) { throw new Exceptions.DataErrorException("从图像中提取的颜色集合与给定的判定数据大小不符合!"); } for (int y = 0; y < DecisionData.ColorCollection.Y; y++) { for (int x = 0; x < DecisionData.ColorCollection.X; x++) { if (!IsSimilarColor(DecisionData.ColorCollection[x, y], data.ColorCollection[x, y], rin)) { return(false); } } } Delay(Random(2, 10)); return(true); } finally { GlobalObject.GetUIForm().ChangeJudgeCoordinate(data.XYToStr, 1); } } }
/// <summary> /// 移除线程 /// </summary> /// <param name="thread"></param> public static void RemoveThread(NokiKanColle.Utility.ThreadsWrapper thread) { GlobalObject.GetUIForm().RemoveThreadItem(thread.Name); GlobalObject.TotalThread.Remove(thread); }
/// <summary> /// 向日志添加一条错误 /// </summary> /// <param name="log"></param> public static void Write(Log log) { //MessageBox.Show("添加了一条错误:"+log.Message); GlobalObject.GetUIForm().AddStatusMessage(log.ShortMessage); //_logFile.WriteLineAsync(log.Message); }