/// <summary> /// 如出现在边界外,获取该值的目标坐标并且返回可能的实际坐标值 /// </summary> /// <param name="po"></param> /// <param name="wantpo"></param> /// <param name="realpo"></param> /// <returns></returns> private void DoMove(GameCoordinate wantpo) { //确定移动的方向 int[] arr = { 0, 0 }; if (wantpo.X > (int)(548 / 2)) //x轴方向 { arr[0] = 1; //右移动 } else if (wantpo.X < (int)(548 / 2)) { arr[0] = -1;//左移动 } else { arr[0] = 0; //不移动 } if (wantpo.Y > (int)(278 / 2)) //y轴方向 { arr[1] = 1; //上移动 } else if (wantpo.Y < (int)(278 / 2)) { arr[1] = -1;//下移动 } else { arr[1] = 0;//不移动 } //推测4个象限的落点可能性 //TODO(是否需要判断多次),x轴右边的,则给他目标值偏差30px int x = 0; if (arr[0] > 0) { //TODO(548和1),对应地图移动距离 x = (548 - wantpo.X) * 1 - 30 * 1; } if (arr[0] < 0) { x = 30 * 1 - wantpo.X * 1; } int y = 0; if (arr[1] > 0) { //TODO(278和1),对应地图移动距离 y = -1 * ((278 - wantpo.Y) * 1 - 30 * 1); } if (arr[1] < 0) { x = -1 * (30 * 1 - wantpo.Y * 1); } //移动 WindowAPI.MMouseMove(0, x, y); }
/// <summary> ///人物请保持静止!!!往指定方向走一走,有1-2的误差! /// </summary> public void MMoveRealCoor(int x, int y) { ActiveWindow(); //先放到指定位置 MPutToPerson(); log.Info("防止正中央"); new GameCommonUtil().ThreadRest(2); PingBiPlayer(); //初始化目标地址 WindowAPI.MMouseMove(0, Singleton.GetInstance().GameBili *x, -y * Singleton.GetInstance().GameBili); //校准偏差 JiaoZhunMouse(false); }
/// <summary> /// /// </summary> /// <param name="pc"></param> public void JiaoZhunMouse(bool isAbsolute) { Point po = new Point(); WindowAPI.GetCursorPos(out po); ResetPC(); if (isAbsolute) { WindowAPI.MMouseMove(0, AbsolutePC[0], -AbsolutePC[1]); } else { WindowAPI.MMouseMove(0, RelativePC[0], -RelativePC[1]); } }
/// <summary> /// move方法,每次move下,1格格move回 /// </summary> /// <param name="city"></param> /// <param name="targetGC_JQ"></param> public void Move11Step(City city, GameCoordinate targetGC_JQ, ref int times) { //看下目标点的落点,理论落点 if (targetGC_JQ.X > city.MapCenterCoor.X && targetGC_JQ.Y > city.MapCenterCoor.Y) { //第一象限,看下与最大值的哪个差的多,做左下方移动 if (Math.Abs(city.MapMaxGameCoor.X - targetGC_JQ.X) < Math.Abs(city.MapMaxGameCoor.Y - targetGC_JQ.Y)) { //大概率y轴方向,则延y轴移动2格子,移动 WindowAPI.MMouseMove(0, -2, 0); times++; if (times > 5) { //大概率y轴方向,则延y轴移动2格子,移动 WindowAPI.MMouseMove(0, 0, -2); times++; } } else { //大概率y轴方向,则延y轴移动2格子,移动 WindowAPI.MMouseMove(0, 0, -2); times++; if (times > 30) { //大概率y轴方向,则延y轴移动2格子,移动 WindowAPI.MMouseMove(0, -2, 0); times++; } } } else if (targetGC_JQ.X <= city.MapCenterCoor.X && targetGC_JQ.Y > city.MapCenterCoor.Y) { //第二象限 //第一象限,看下与最大值的哪个差的多,做左下方移动 if (Math.Abs(targetGC_JQ.X - 0) < Math.Abs(city.MapMaxGameCoor.Y - targetGC_JQ.Y)) { //大概率y轴方向,则延y轴移动2格子,移动 WindowAPI.MMouseMove(0, 2, 0); times++; if (times > 30) { //大概率y轴方向,则延y轴移动2格子,移动 WindowAPI.MMouseMove(0, 0, -2); times++; } } else { //大概率y轴方向,则延y轴移动2格子,移动 WindowAPI.MMouseMove(0, 0, -2); times++; if (times > 30) { //大概率y轴方向,则延y轴移动2格子,移动 WindowAPI.MMouseMove(0, 2, 0); times++; } } } else if (targetGC_JQ.X <= city.MapCenterCoor.X && targetGC_JQ.Y <= city.MapCenterCoor.Y) { //第三象限右上 if (Math.Abs(targetGC_JQ.X - 0) < Math.Abs(city.MapMaxGameCoor.Y - 0)) { //大概率y轴方向,则延y轴移动2格子,移动 WindowAPI.MMouseMove(0, 2, 0); times++; if (times > 30) { //大概率y轴方向,则延y轴移动2格子,移动 WindowAPI.MMouseMove(0, 0, 2); times++; } } else { //大概率y轴方向,则延y轴移动2格子,移动 WindowAPI.MMouseMove(0, 0, 2); times++; if (times > 30) { //大概率y轴方向,则延y轴移动2格子,移动 WindowAPI.MMouseMove(0, 2, 0); times++; } } } else { //第4象限坐上 if (Math.Abs(city.MapMaxGameCoor.X - targetGC_JQ.X) < Math.Abs(city.MapMaxGameCoor.Y - 0)) { //大概率y轴方向,则延y轴移动2格子,移动 WindowAPI.MMouseMove(0, -2, 0); times++; if (times > 30) { //大概率y轴方向,则延y轴移动2格子,移动 WindowAPI.MMouseMove(0, 0, 2); times++; } } else { //大概率y轴方向,则延y轴移动2格子,移动 WindowAPI.MMouseMove(0, 0, 2); times++; if (times > 30) { //大概率y轴方向,则延y轴移动2格子,移动 WindowAPI.MMouseMove(0, -2, 0); times++; } } } }