public static bool findAndClickImage(Bitmap image, string imageName = "image", bool cropMode = false, int x = 0, int y = 0, int width = 0, int height = 0, bool capture = false, bool recheck = false) { Point?imageResult = findGameImage(image, imageName, cropMode, x, y, width, height, capture); int i = 0; if (imageResult != null) { clickImage(image, imageResult.Value.X + x, imageResult.Value.Y + y, imageName); while (i < 3 && recheck) { GameHelper.Delay(500); imageResult = findGameImage(image, imageName, cropMode, x, y, width, height, false); if (imageResult != null) { clickImage(image, imageResult.Value.X + x, imageResult.Value.Y + y, imageName); i++; } else { return(true); } } GameHelper.Log("Found " + imageName); return(true); } GameHelper.Log("Cant find " + imageName); return(false); }
public static int findShiki(int swipeCount) { int start_y = 441; int start_x = 136; int end_x = 917; int width = 113; int height = 161; var current_x = start_x; Bitmap[] imagesFind = { shikiMaxImage, shikiFightImage }; List <int> searchResult = null; while (!Global.isStop && current_x < end_x) { searchResult = GameImage.findMultiGameImage(imagesFind, true, current_x, start_y, width, height); if (searchResult.Count < 1) { return(current_x); } else { GameHelper.Log("Khong hop le"); current_x += width; } } return(-1); }
public static bool clickToMonster(Point?monsterLocation) { int i = 0; Point?fightExpMonsterImage = null; GameHelper.Log("Finding to fight...."); while (i < 5) { fightExpMonsterImage = GameImage.findGameImage(fightImage, "Fight Monster", true, monsterLocation.Value.X - 150, monsterLocation.Value.Y - 250, 300, 300); if (fightExpMonsterImage != null) { GameImage.clickImage(fightImage, fightExpMonsterImage.Value.X + monsterLocation.Value.X - 150, fightExpMonsterImage.Value.Y + monsterLocation.Value.Y - 250, "Fight Monster"); GameHelper.Log("Click to fight exp monster"); return(true); } i++; GameHelper.Delay(100); } if (fightExpMonsterImage == null) { fightExpMonsterImage = GameImage.findGameImage(bossImage, "Fight BOSS", true, monsterLocation.Value.X - 100, monsterLocation.Value.Y - 300, 200, 300); if (fightExpMonsterImage != null) { GameImage.clickImage(bossImage, fightExpMonsterImage.Value.X + monsterLocation.Value.X - 100, fightExpMonsterImage.Value.Y + monsterLocation.Value.Y - 250, "Fight Boss"); } } if (fightExpMonsterImage == null) { GameHelper.Log("Found fight image of exp monster Fail"); } return(false); }
private void autoCloseGame_CheckedChanged(object sender, EventArgs e) { CheckBox nb = sender as CheckBox; Global.autoClose = nb.Checked; GameHelper.Log("Tự động tắt game" + nb.Checked.ToString()); }
public static bool waitBattleReady() { if (GameImage.waitGameImage(battleLoadedImage, 10000, 2000) == true) { GameHelper.Log("Battle Ready"); return(true); } return(false); }
public static ShikiFood findShikiFood(int foodType = 0, List <int> shikiMaxPositions = null) { /* * foodType: 0 => N ; 1 => Daruma ; 2 => R */ GameHelper.Log(foodType.ToString()); if (foodType > 2 || foodType < 0) { foodType = 0; } int[] shikiTypePos = GamePos.shikiTypeButton[foodType]; GameHelper.Delay(500); GameImage.waitGameImage(allShikiImage, 5000, 1000); GameHelper.clickRandomArea(GamePos.allShikiButton[0], GamePos.allShikiButton[1], GamePos.allShikiButton[2], GamePos.allShikiButton[3]); GameHelper.Delay(1000); GameHelper.clickRandomArea(shikiTypePos[0], shikiTypePos[1], shikiTypePos[2], shikiTypePos[3]); GameHelper.Delay(1000); if (shikiMaxPositions.Count > 0) { int swipeCount = 0; shikiMaxPositions.ForEach(delegate(int position) { int[] shikiMaxPos = GamePos.shikiPositionDrag[position]; while (swipeCount < 3) { int shikiStartX = findShiki(swipeCount); if (shikiStartX != -1) { GameHelper.Delay(1000); //GameHelper.dragAndDropGame(shikiStartX + 50, 490, shikiMaxPos[0] + (shikiMaxPos[2] - shikiMaxPos[0]) / 2, shikiMaxPos[1] + (shikiMaxPos[3] - shikiMaxPos[1]) / 2); Point point1 = new Point(); point1.X = shikiStartX + 50; point1.Y = 490; Point point2 = new Point(); point2.X = point1.X; point2.Y = shikiMaxPos[1]; Point point3 = new Point(); point3.X = shikiMaxPos[0] + (shikiMaxPos[2] - shikiMaxPos[0]) / 2; point3.Y = point2.Y; Point[] points = { point1, point2, point3 }; GameHelper.dragAndDropMultiGame(points); GameHelper.Delay(1500); break; } else { GameHelper.dragAndDropGame(903, 541, 201, 531); swipeCount++; } } }); } //go to food storage return(null); }
public static bool isExploreArea() { bool result = GameImage.waitGameImage(yingbingImage, 50000, 1000, true); if (result == true) { GameHelper.Log("In Explore Area"); return(true); } return(false); }
public static void closeGame() { GameHelper.Log("Tat game di ngu"); //isStop = true; if (autoClose == true) { foreach (var process in Process.GetProcessesByName("client")) { process.Kill(); } } }
void getOnmyojiHandle() { Global.mainHandle = AutoControl.FindWindowHandle(null, "Onmyoji"); if (Global.mainHandle == IntPtr.Zero) { GameHelper.Log("Khong tim thay cua so game. Vui long mo game truoc khi tiep tuc"); return; } else { GameHelper.Log("Da tim thay cua so game"); } }
private void explore_button_Click(object sender, EventArgs e) { Explore.setFoodType(cbxFoodType.SelectedIndex); Global.isStop = false; Task t = new Task(() => { while (!Global.isStop) { Explore.ExploreAction(); } GameHelper.Log("Explore Finish"); }); t.Start(); }
public static void clickImage(Bitmap image, int x, int y, string imageName = "image", bool doubleClick = false) { /*int _x = GameRandom.RandomNumber(x, x + 5); * int _y = GameRandom.RandomNumber(y, y + 5); * int _x2 = GameRandom.RandomNumber(x, x + 10); * int _y2 = GameRandom.RandomNumber(y, y + 10);*/ //AutoControl.SendClickOnPosition(Global.mainHandle, x, y, EMouseKey.LEFT); AutoControl.SendDragAndDropOnPosition(Global.mainHandle, x, y, x + 1, y + 1, 10, 10, 0.2); if (doubleClick) { AutoControl.SendDragAndDropOnPosition(Global.mainHandle, x, y, x + 1, y + 1); //AutoControl.SendClickOnPosition(Global.mainHandle, x, y, EMouseKey.LEFT); GameHelper.Log("Double Clicked to " + imageName); } else { GameHelper.Log("Clicked to " + imageName); } }
public static bool waitBattleEnd() { Bitmap[] images = { loseImage, goldImage }; List <int> imageResult = new List <int>(); int i = 0; while (i < 20) { GameHelper.Delay(3000); imageResult = GameImage.findMultiGameImage(images); if (imageResult.Count() > 0) { break; } i++; } if (imageResult.Count() < 1) { GameHelper.Log("Battle Error"); return(false); } if (imageResult[0] == 1) { GameHelper.Log("Win Battle"); return(true); } if (imageResult[0] == 0) { GameHelper.Log("Lose Battle"); return(true); } /*bool result = GameImage.waitGameImage(goldImage, 100000, 5000); * if (result == true) * { * GameHelper.Log("End Battle"); * return true; * }*/ return(false); }
public static List <int> checkFoodFullExp() { List <int> result = new List <int>(); if (GameImage.findGameImage(maxLvlImage, "Max exp image", true, GamePos.shikiCenterBattle[0], GamePos.shikiCenterBattle[1], GamePos.shikiCenterBattle[2] - GamePos.shikiCenterBattle[0], GamePos.shikiCenterBattle[3] - GamePos.shikiCenterBattle[1]) != null) { result.Add(1); } if (GameImage.findGameImage(maxLvlImage, "Max exp image", true, GamePos.shikiRightBattle[0], GamePos.shikiRightBattle[1], GamePos.shikiRightBattle[2] - GamePos.shikiRightBattle[0], GamePos.shikiRightBattle[3] - GamePos.shikiRightBattle[1]) != null) { result.Add(2); } if (result.Count > 0) { GameHelper.Log("Click to change shiki"); GameHelper.clickGame(655, 482, true); GameHelper.Delay(1000); ShikiFood.findShikiFood(foodType, result); } return(result); }
public static Point?findExpMonster() { int i = 0; Point?expMonsterImage = null; Image scene = null;; GameHelper.Log("Finding exp monster...."); while (i < 5) { scene = CaptureHelper.CaptureWindow(Global.mainHandle); expMonsterImage = ImageScanOpenCV.FindOutPoint((Bitmap)scene, expImage); //expMonsterImage = GameImage.findGameImage(expImage); if (expMonsterImage != null) { GameHelper.Log("Found Exp Monster(Middle)!!!"); break; } expMonsterImage = ImageScanOpenCV.FindOutPoint((Bitmap)scene, nearExpImage); if (expMonsterImage != null) { GameHelper.Log("Found Exp Monster(Near)!!!"); break; } expMonsterImage = ImageScanOpenCV.FindOutPoint((Bitmap)scene, farExpImage); if (expMonsterImage != null) { GameHelper.Log("Found Exp Monster(Far)!!!"); break; } i++; GameHelper.Delay(200); } if (expMonsterImage == null) { GameHelper.Log("Found Exp Monster Fail!!!"); } return(expMonsterImage); }
public static void ExploreAction() { GameHelper.Log("Start new Explore"); if (GameImage.waitGameImage(exploreImage, 100000, 1000, true) == false) { Global.isStop = true; return; } clickExplore(); GameHelper.Delay(516); if (isExploreArea() != true) { Global.isStop = true; return; } GameHelper.Delay(525); swipeToNextExplore(); GameHelper.Delay(525); findAndAttackExpMonster(); GameHelper.Delay(525); exitExploreArea(); GameHelper.Delay(528); }
public static void swipeToNextExplore() { GameHelper.Log("Swipe"); AutoControl.SendDragAndDropOnPosition(Global.mainHandle, 1077, 85, 385, 83, 10, 10, 0.01); GameHelper.Delay(1230); }