// Checks if duel is finished, with a parameter to extend time between checks public static void checkIfDuelEnded(int timeBetweenChecks) { tempScreenshot = BitmapGraphics.Screenshot(); logButtonExists = BitmapGraphics.FindBitMap(Properties.Resources.bmpLogButton, tempScreenshot, out location); int timeToIncreaseBetweenChecks = 0; if (logButtonExists) { isDuelOver = true; frm.displayText("Ending duel."); CursorPath.FreezeInput(); frm.changeButtonColor(Color.Red); BitmapGraphics.FindBitMap(Properties.Resources.bmpLogButton, tempScreenshot, out location); Cursor.Position = location; location = new Point(Cursor.Position.X - 150, Cursor.Position.Y + 120); Cursor.Position = location; MouseActions.MouseClick(); BitmapGraphics.disposeGraphic(tempScreenshot); clickThroughDialogs(); } else if (!logButtonExists) { frm.displayText("Checking if duel ended."); Thread.Sleep(timeBetweenChecks); BitmapGraphics.disposeGraphic(tempScreenshot); checkIfDuelEnded(timeBetweenChecks + timeToIncreaseBetweenChecks); } }
// When button is clicked, dueling begins private void button1_Click(object sender, EventArgs e) { displayText("Started."); CursorPath.FreezeInput(); changeButtonColor(Color.Red); Bitmap bmpScreenshot = BitmapGraphics.Screenshot(); Bitmap initialScrenshot = BitmapGraphics.Screenshot(); Point location; CursorPath.setAnchorImage("bmpPanel2"); CursorPath.setInitialLocation(-175, -140); /*var images = Properties.Resources.ResourceManager * .GetResourceSet(System.Globalization.CultureInfo.CurrentCulture, true, true) * .Cast<System.Collections.DictionaryEntry>() * .Where(x => x.Value.GetType() == typeof(Bitmap)) * .Select(x => x.Key.ToString()) * .ToList();*/ String[] panels = new String[4] { "bmpPanel2", "bmpPanel3", "bmpPanel4", "bmpPanel1" }; bool[] skipPanels = new bool[4] { skipCheckbox1, skipCheckbox2, skipCheckbox3, skipCheckbox4 }; Delegate[] findDuelistMethods = new Delegate[4]; findDuelistMethods[0] = new delWithNoParameters(CursorPath.duelAtGate); findDuelistMethods[1] = new delWithNoParameters(CursorPath.duelAtPVPArena); findDuelistMethods[2] = new delWithNoParameters(CursorPath.duelAtShop); findDuelistMethods[3] = new delWithNoParameters(CursorPath.duelAtCardStudio); int j = 0; int numberOfTimesToCheck = Int32.Parse(textBox1.Text); foreach (String p in panels) { Bitmap duelingZones = (Bitmap)Properties.Resources.ResourceManager.GetObject(p); for (int i = 0; i < numberOfTimesToCheck; i++) { if (skipPanels[j]) { skipPanels[j] = false; break; } findDuelistMethods[j].DynamicInvoke(); } initialScrenshot = BitmapGraphics.Screenshot(); BitmapGraphics.FindBitMap(duelingZones, initialScrenshot, out location); Cursor.Position = location; MouseActions.MouseClick(); BitmapGraphics.disposeGraphic(initialScrenshot); j++; } CursorPath.ThawInput(); changeButtonColor(Color.LightGreen); displayText("Finished."); }