/// <summary> /// 查找指定区域是否存在图片,存在则点击图片,直到图片消失 /// </summary> /// <param name="_dm"></param> /// <param name="x1"></param> /// <param name="y1"></param> /// <param name="x2"></param> /// <param name="y2"></param> /// <param name="picname"></param> /// <param name="a"></param> /// <param name="b"></param> /// <param name="delay"></param> /// <returns></returns> public static bool FindPicAndClickClear(this DmPlugin _dm, int x1, int y1, int x2, int y2, string picname, int a = 0, int b = 0, int delay = 1000) { int intX, intY; while (true) { _dm.FindPic(x1, y1, x2, y2, picname, "101010", 0.9, 0, out intX, out intY); if (intX > 0 && intY > 0) { _dm.MoveToClick(intX + a, intY + b); _dm.Delay(delay); _dm.FindPic(x1, y1, x2, y2, picname, "101010", 0.9, 0, out intX, out intY); if (intX < 0 && intY < 0) { return(true); } } else { return(true); } _dm.Delay(50); } }
public bool GoToFubenArea(string area) { List <string> areas = new List <string>() { "虎牢关", "下邳", "官渡", "西蜀" }; string currentArea = ""; int intX, intY, i = 0; foreach (var a in areas) { _dm.FindPic(320, 453, 640, 534, @"\bmp\" + a + ".bmp", "303030", 0.7, 0, out intX, out intY); if (intX > 0 && intY > 0) { _dm.DebugPrint("当前位于副本区域[" + a + "]"); currentArea = a; break; } } if (currentArea == area) { _dm.DebugPrint("已经在副本区域[" + area + "]"); return(true); } _dm.DebugPrint("正在移动到目标区域..."); return(Delegater.WaitTrue(() => { _dm.FindPic(320, 453, 640, 534, @"\bmp\" + area + ".bmp", "303030", 0.7, 0, out intX, out intY); if (intX > 0 && intY > 0) { _dm.DebugPrint("已经在副本区域[" + area + "]"); return true; } else { int index = areas.IndexOf(area); foreach (var a in areas) { _dm.FindPic(320, 453, 640, 534, @"\bmp\" + a + ".bmp", "303030", 0.7, 0, out intX, out intY); if (intX > 0 && intY > 0) { _dm.DebugPrint("当前位于副本区域[" + a + "]"); currentArea = a; break; } } int currentIndex = areas.IndexOf(currentArea); if (index > currentIndex) { _dm.Swipe(670, 427, 93, 415); } if (index < currentIndex) { _dm.Swipe(93, 415, 670, 427); } } return false; }, () => _dm.Delay(1000))); }
/// <summary> /// 查找指定区域是否存在图片,存在则点击图片,可设置偏移 /// </summary> /// <param name="_dm"></param> /// <param name="x1"></param> /// <param name="y1"></param> /// <param name="x2"></param> /// <param name="y2"></param> /// <param name="picname"></param> /// <param name="a"></param> /// <param name="b"></param> /// <param name="sim"></param> /// <returns></returns> public static bool FindPicAndClick(this DmPlugin _dm, int x1, int y1, int x2, int y2, string picname, int a = 0, int b = 0, double sim = 0.8) { int intX, intY; _dm.FindPic(x1, y1, x2, y2, picname, "202020", sim, 0, out intX, out intY); if (intX > 0 && intY > 0) { _dm.DebugPrint("找图[" + picname + "]成功!" + "坐标:" + intX + " " + intY); _dm.MoveToClick(intX + a, intY + b); _dm.Delay(50); return(true); } _dm.DebugPrint("找图[" + picname + "]失败!"); return(false); }
/// <summary> /// 查找区域是否存在指定图片 /// </summary> /// <param name="_dm"></param> /// <param name="x1"></param> /// <param name="y1"></param> /// <param name="x2"></param> /// <param name="y2"></param> /// <param name="picname"></param> /// <param name="sim"></param> /// <param name="isShow"></param> /// <returns></returns> public static bool IsExistPic(this DmPlugin _dm, int x1, int y1, int x2, int y2, string picname, double sim = 0.8, bool isShow = true) { int intX, intY; _dm.FindPic(x1, y1, x2, y2, picname, "202020", sim, 0, out intX, out intY); if (intX > 0 && intY > 0) { _dm.DebugPrint("存在图片【" + picname + "】!", isShow); return(true); } else { _dm.DebugPrint("不存在图片【" + picname + "】!", isShow); return(false); } }