public static bool CheckObstacles() { ClickablePoint messagePos = CoCHelper.SearchPixelInRect(ScreenData.Inactivity); if (!messagePos.IsEmpty) { CoCHelper.Click(ScreenData.ReloadButton); Thread.Sleep(7000); return(true); } if (CoCHelper.CheckPixelColor(ScreenData.Attacked)) { CoCHelper.Click(ScreenData.AttackedBtn); return(true); } // The main screen if (CoCHelper.CheckPixelColor(ScreenData.IsMainGrayed)) { CoCHelper.Click(ScreenData.TopLeftClient); return(true); } // If we have a screen with a small x to cancel it, like when you start a fight. if (CoCHelper.CheckPixelColor(ScreenData.SomeXCancelBtn)) { CoCHelper.Click(ScreenData.SomeXCancelBtn); return(true); } // If a fight is on going, than cancel it. if (CoCHelper.CheckPixelColor(ScreenData.CancelFight) || CoCHelper.CheckPixelColor(ScreenData.CancelFight2)) { CoCHelper.Click(ScreenData.CancelFight); return(true); } if (CoCHelper.CheckPixelColorBad(new Point(331, 330), Color.FromArgb(240, 160, 59), 20)) { CoCHelper.ClickBad(new Point(331, 330), 1); Thread.Sleep(1000); return(true); } if (CoCHelper.CheckPixelColorBad(new Point(429, 519), Color.FromArgb(184, 227, 95), 20)) { CoCHelper.ClickBad(new Point(429, 519), 1); return(true); } if (CoCHelper.CheckPixelColorBad(new Point(71, 530), Color.FromArgb(192, 0, 0), 20)) { CoCHelper.ClickBad(new Point(331, 330), 1); ReturnHome(false, false); return(true); } return(false); }
public static void WaitForMainScreen() { Main.Bot.WriteToOutput("Waiting for Main Screen"); for (int i = 0; i < 150; i++) { if (!CoCHelper.CheckPixelColor(ScreenData.IsMain)) { Thread.Sleep(2000); if (CheckObstacles()) { i = 0; } } else { return; } } Main.Bot.WriteToOutput("Unable to load Clash of Clans, Restarting..."); ClickablePoint appPos = GetAppPos(); CoCHelper.Click(appPos, 1); Thread.Sleep(10000); }
public static void PrepareSearch() { Main.Bot.WriteToOutput("Preparing Search..."); CoCHelper.Click(ScreenData.AttackButton); Thread.Sleep(1000); CoCHelper.Click(ScreenData.MatchButton); Thread.Sleep(3000); if (CoCHelper.CheckPixelColor(ScreenData.HasShield)) { CoCHelper.Click(ScreenData.BreakShield); } }
public static void CheckMainScreen() { Main.Bot.WriteToOutput(Properties.Resources.OutputTryingToLocateMainScreen, GlobalVariables.OutputStates.Information); while (!CoCHelper.CheckPixelColor(ScreenData.IsMain)) { Thread.Sleep(1000); if (!CheckObstacles()) { ClickablePoint appPos = GetAppPos(); CoCHelper.Click(appPos, 1); } WaitForMainScreen(); } Main.Bot.WriteToOutput("Main Screen Located", GlobalVariables.OutputStates.Information); }
public bool CheckFrom(int x, int y) { return(CoCHelper.CheckPixelColor(new DetectablePoint(x + DeltaX, y + DeltaY, Color, ShadeVariation))); }
public static bool VillageSearch() { switch (Main.Bot.SelectedAttackMode) { case AttackMode.AllBases: Main.Bot.WriteToOutput("============Searching For All Bases============", GlobalVariables.OutputStates.Information); break; case AttackMode.DeadBases: Main.Bot.WriteToOutput("============Searching For Dead Bases============", GlobalVariables.OutputStates.Information); break; case AttackMode.WeakBases: Main.Bot.WriteToOutput("============Searching For Weak Bases============", GlobalVariables.OutputStates.Information); break; } Main.Bot.WriteToOutput("~Gold: " + Main.Bot.MinimumGold + "; Elixir: " + Main.Bot.MinimumElixir + "; Dark Elixir: " + Main.Bot.MinimumDarkElixir + "; Trophies: " + Main.Bot.MinimumTrophyCount + ";"); while (true) { var timeout = 0; while (!CoCHelper.CheckPixelColor(ScreenData.NextBtn)) { if (timeout >= 20) // After 10 seconds { return(false); } timeout++; Thread.Sleep(500); } if (CompareResources()) { if (Main.Bot.SelectedAttackMode.Equals(AttackMode.DeadBases)) { if (CheckDeadBase()) { Main.Bot.WriteToOutput("~~~~~~~ Dead Base Found! ~~~~~~~"); return(true); } Main.Bot.WriteToOutput("~~~~~~~ Not Dead Base, Skipping ~~~~~~~"); CoCHelper.Click(ScreenData.NextBtn); } else if (Main.Bot.SelectedAttackMode.Equals(AttackMode.WeakBases)) { if (CheckWeakBase()) { Main.Bot.WriteToOutput("~~~~~~~ Weak Base Found! ~~~~~~~"); return(true); } Main.Bot.WriteToOutput("~~~~~~~ Not Weak Base, Skipping ~~~~~~~"); CoCHelper.Click(ScreenData.NextBtn); } else { return(true); } } else { CoCHelper.Click(ScreenData.NextBtn); Thread.Sleep(1000); } } }