// Find duel button
        public static void locateDuelButton()
        {
            tempScreenshot   = BitmapGraphics.Screenshot();
            duelButtonExists = BitmapGraphics.FindBitMap(Properties.Resources.bmpBackArrow, tempScreenshot, out location);

            frm.displayText("Trying to find duel button.");

            if (duelButtonExists)
            {
                Cursor.Position = location;
                location        = new Point(Cursor.Position.X + 230, Cursor.Position.Y + -65);
                clickDuelButton();
                waitAndFindAutoDuelButton();
                checkIfDuelEnded(5000);
            }
            else if (BitmapGraphics.FindBitMap(Properties.Resources.bmpDuelButton, tempScreenshot, out location))
            {
                clickDuelButton();
                waitAndFindAutoDuelButton();
                checkIfDuelEnded(5000);
            }
            else
            {
                BitmapGraphics.disposeGraphic(tempScreenshot);
            }
        }
        // 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);
            }
        }
        // Check if duel button exists, or if 'OK' dialog pops up and returns cursor to origina location after it clicks it
        public static bool isDuelButton(Point originalLocation)
        {
            tempScreenshot   = BitmapGraphics.Screenshot();
            duelButtonExists = BitmapGraphics.FindBitMap(Properties.Resources.bmpBackArrow, tempScreenshot, out location);

            if (duelButtonExists)
            {
                BitmapGraphics.disposeGraphic(tempScreenshot);
                return(duelButtonExists);
            }
            else if (BitmapGraphics.FindBitMap(Properties.Resources.bmpDuelButton, tempScreenshot, out location))
            {
                BitmapGraphics.disposeGraphic(tempScreenshot);
                return(true);
            }
            else if (BitmapGraphics.FindBitMap(Properties.Resources.bmpOKButton, tempScreenshot, out location))
            {
                Cursor.Position = location;
                MouseActions.MouseClick();
                BitmapGraphics.disposeGraphic(tempScreenshot);
                Cursor.Position = originalLocation;
                return(false);
            }
            else
            {
                BitmapGraphics.disposeGraphic(tempScreenshot);
                return(false);
            }
        }
Example #4
0
        // Sets an anchor image as a reference location for the start point
        public static void setAnchorImage(String resourceName)
        {
            Bitmap panels = (Bitmap)Properties.Resources.ResourceManager.GetObject(resourceName);

            BitmapGraphics.FindBitMap(panels, initialScrenshot, out location);
            Cursor.Position = location;
        }
Example #5
0
        // 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.");
        }
 // Click duel button
 private static void clickDuelButton()
 {
     Cursor.Position = location;
     MouseActions.MouseClick();
     Thread.Sleep(2000);
     MouseActions.MouseClick();
     frm.displayText("Clicked on duel button.");
     BitmapGraphics.disposeGraphic(tempScreenshot);
 }
 // Clicks auto duel button
 private static void clickAutoDuelButton()
 {
     Cursor.Position = location;
     MouseActions.MouseClick();
     BitmapGraphics.disposeGraphic(tempScreenshot);
     frm.displayText("Clicked on auto-duel.");
     CursorPath.ThawInput();
     frm.changeButtonColor(Color.LightGreen);
     Thread.Sleep(30000);
 }
        // Check for additional character dialog after all clicks
        private static void checkForAdditionalChatDialog()
        {
            tempScreenshot = BitmapGraphics.Screenshot();
            bool secondDialog = BitmapGraphics.FindBitMap(Properties.Resources.bmpBeforeAfterDuel, tempScreenshot, out location);

            if (secondDialog)
            {
                Cursor.Position = location;
                MouseActions.MouseClick();
                BitmapGraphics.disposeGraphic(tempScreenshot);
                Thread.Sleep(4000);
            }
            else
            {
                BitmapGraphics.disposeGraphic(tempScreenshot);
            }
        }
        // Chcecks for an "OK" button that pops up after all character dialogs
        private static void checkForFinalOKButton()
        {
            frm.displayText("Waiting for possible additional dialogs...");
            tempScreenshot = BitmapGraphics.Screenshot();
            bool finalOk = BitmapGraphics.FindBitMap(Properties.Resources.bmpCampReward, tempScreenshot, out location);

            if (finalOk)
            {
                Cursor.Position = location;
                MouseActions.MouseClick();
                BitmapGraphics.disposeGraphic(tempScreenshot);
                Thread.Sleep(2000);
            }
            else
            {
                BitmapGraphics.disposeGraphic(tempScreenshot);
            }
        }
        // Finds auto duel button
        public static void locateAutoDuelButton()
        {
            tempScreenshot = BitmapGraphics.Screenshot();
            MouseActions.MouseClick();
            frm.displayText("Trying to find auto-duel button.");

            if (BitmapGraphics.FindBitMap(Properties.Resources.bmpAutoDuelButton, tempScreenshot, out location))
            {
                clickAutoDuelButton();
            }
            else if (BitmapGraphics.FindBitMap(Properties.Resources.bmpAutoDuelButton2, tempScreenshot, out location))
            {
                clickAutoDuelButton();
            }
            else
            {
                BitmapGraphics.disposeGraphic(tempScreenshot);
                MouseActions.MouseClick();
                Thread.Sleep(3000);
                locateAutoDuelButton();
            }
        }