public override void Tick(Bitmap viewportCapture, RECT viewportRect) { var viewportMat = viewportCapture.ToOpenCvMat(); if (TryClickNextTag(viewportMat, viewportRect)) { logTools.Info("TryClickNextTag"); } else if (TryClickChallengeButton(viewportMat, viewportRect)) { logTools.Info("TryClickChallengeButton"); } else if (TryClickStartFightButton(viewportMat, viewportRect)) { logTools.Info("TryClickStartFightButton"); } else if (TryClickAutoOffButton(viewportMat, viewportRect)) { logTools.Info("TryClickAutoOffButton"); } else if (TryClickNextStepButton(viewportMat, viewportRect)) { logTools.Info("TryClickNextStepButton"); } else { logTools.Info("ClickBack"); MumuState.DoClick(viewportRect, new Vec2f(0.1f, 0.7f)); //MumuState.ClickBack(viewportRect); } }
public void ClickListItem(RECT viewportRect, Vec4f listRectRate, RECT listItemNewTagRect) { var newTagAbsoluteRect = GetMatchedAbsoluteRect(viewportRect, listRectRate, listItemNewTagRect); //这个是opencv中的坐标 var clickCvPoint = new RawPoint((newTagAbsoluteRect.x1 + newTagAbsoluteRect.x2) / 2, newTagAbsoluteRect.y2); var emulatorPoint = MumuState.GetEmulatorPoint(viewportRect, clickCvPoint); MumuState.DoClick(emulatorPoint); }
public bool TryClickButton(Mat viewportMat, RECT viewportRect, string exImgName, Vec4f rectRate, double threshold) { var matchRes = MatchImage(viewportMat, viewportRect, rectRate, exImgName, threshold); if (!matchRes.Success) { return(false); } var absoluteRect = GetMatchedAbsoluteRect(viewportRect, rectRate, matchRes.MatchedRect); var centerPos = absoluteRect.GetCenterPos(); var emulatorPoint = MumuState.GetEmulatorPoint(viewportRect, centerPos); MumuState.DoClick(emulatorPoint); return(true); }
public bool TryClickNextTag(Mat viewportMat, RECT viewportRect) { var threshold = 0.6; var rectRate = new Vec4f(0.0044f, 0.1122f, 0.9833f, 0.8950f); var matchRes = MatchImage(viewportMat, viewportRect, rectRate, "battle_next_tag.png", threshold); if (!matchRes.Success) { return(false); } var absoluteRect = GetMatchedAbsoluteRect(viewportRect, rectRate, matchRes.MatchedRect); var pos = absoluteRect.GetCenterPos(); pos.Y = pos.Y + (int)(viewportRect.Height * 0.1500f); var emulatorPoint = MumuState.GetEmulatorPoint(viewportRect, pos); MumuState.DoClick(emulatorPoint); return(true); }
public bool ClickConfrimIfHas(Mat viewportMat, RECT viewportRect) { var skipConfirmButtonRectRate = new Vec4f(0.5364f, 0.6254f, 0.6674f, 0.7493f); var matchRes = MatchImage(viewportMat, viewportRect, skipConfirmButtonRectRate, "skip_confirm_button.png"); if (!matchRes.Success) { return(false); } var confirmAbsoluteRect = GetMatchedAbsoluteRect(viewportRect, skipConfirmButtonRectRate, matchRes.MatchedRect); //这个是opencv中的坐标 var cvX = (confirmAbsoluteRect.x1 + confirmAbsoluteRect.x2) / 2; var cvY = (confirmAbsoluteRect.y1 + confirmAbsoluteRect.y2) / 2; var clickCvPoint = new RawPoint(cvX, cvY); var emulatorPoint = MumuState.GetEmulatorPoint(viewportRect, clickCvPoint); MumuState.DoClick(emulatorPoint); return(true); }
public void DoEpisodeSceneThings(Mat viewportMat, RECT viewportRect) { logTools.Info("DoEpisodeSceneThings"); var threshold = 0.6; var rectRate = new Vec4f(0.0408f, 0.0350f, 0.9651f, 0.8499f); var matchRes = MatchImage(viewportMat, viewportRect, rectRate, "reliability_episode_new_tag.png", threshold); if (matchRes.Success) { var absoluteRect = GetMatchedAbsoluteRect(viewportRect, rectRate, matchRes.MatchedRect); var emulatorPoint = MumuState.GetEmulatorPoint(viewportRect, absoluteRect.GetCenterPos()); MumuState.DoClick(emulatorPoint); } else { logTools.Info("DoEpisodeSceneThings Cannot Find New Tag"); MumuState.ClickBack(viewportRect); } }
public void DoMainSceneThings(Mat viewportMat, RECT viewportRect) { logTools.Info("DoMainSceneThings"); var listItemNewTagThreshold = 0.6; var listRectRate = new Vec4f(0.5378f, 0.1254f, 0.9760f, 0.8834f); var matchRes = MatchImage(viewportMat, viewportRect, listRectRate, "reliability_new_tag.png", listItemNewTagThreshold); if (matchRes.Success) { var absoluteRect = GetMatchedAbsoluteRect(viewportRect, listRectRate, matchRes.MatchedRect); var emulatorPoint = MumuState.GetEmulatorPoint(viewportRect, absoluteRect.GetCenterPos()); MumuState.DoClick(emulatorPoint); } else { logTools.Info("DoMainSceneThings Cannot Find New Tag"); MumuState.DoDrag(viewportRect, new Vec2f(0.7700f, 0.7012f), new Vec2f(0.7700f, 0.2332f), 1200); } }
public bool TryClickNormalBox(Mat viewportMat, RECT viewportRect) { var threshold = 0.8; var rectRate = fullPartRectRate; var matchRes = MatchImage(viewportMat, viewportRect, rectRate, "underground_normal_box.png", threshold); if (!matchRes.Success) { return(false); } var absoluteRect = GetMatchedAbsoluteRect(viewportRect, rectRate, matchRes.MatchedRect); var left2right = absoluteRect.GetCenterPos().X < 1.0f * viewportRect.Width / 2; var emulatorPoint = MumuState.GetEmulatorPoint(viewportRect, absoluteRect.GetCenterPos()); MumuState.DoClick(emulatorPoint); Thread.Sleep(500); for (int i = 1; i < 3; i++) { if (left2right) { var newX1Rate = 1.0f * absoluteRect.x2 / viewportRect.Width; rectRate.Item0 = newX1Rate; } else { var newX2Rate = 1.0f * absoluteRect.x1 / viewportRect.Width; rectRate.Item2 = newX2Rate; } matchRes = MatchImage(viewportMat, viewportRect, rectRate, "underground_normal_box.png", threshold); if (!matchRes.Success) { break; } absoluteRect = GetMatchedAbsoluteRect(viewportRect, rectRate, matchRes.MatchedRect); emulatorPoint = MumuState.GetEmulatorPoint(viewportRect, absoluteRect.GetCenterPos()); MumuState.DoClick(emulatorPoint); Thread.Sleep(500); } return(true); }