Пример #1
0
 public void Process()
 {
     if (taskStopwatch.DurationInMilliseconds() >= taskDelay)
     {
         taskFinished = true;
         taskAction();
     }
 }
Пример #2
0
        public void runAutoQueue(Bitmap screen)
        {
            //Loop through pixels on the screen and look for any of those four buttons.
            if (lockInButtonStopwatch.DurationInMilliseconds() >= 5000 || VisualCortex.IsTest)
            {
                //Console.WriteLine("Scanning for lock in button");
                lockInButtonPosition = AutoQueueDetection.findImageInScreen(screen, lockInButton, 660, 441, 10, 10, 0.95);
                //acceptMatchButtonPosition = AutoQueueDetection.findImageInScreen(screen, acceptMatchButton, 0, 0, 1024, 768, 0.5);
                if (lockInButtonPosition.x != -1)
                {
                    lockInButtonStopwatch.Reset();
                    Console.WriteLine("\tFound lock in button at " + lockInButtonPosition.x + ", " + lockInButtonPosition.y);
                    if (!VisualCortex.IsTest)
                    {
                        pickedLane = random.Next(3) + 1;

                        Task.Delay(1000).ContinueWith(_ =>
                        {
                            MotorCortex.clickMouseAt(lockInButtonPosition.x + 10, lockInButtonPosition.y + 10);


                            int x = lockInButtonPosition.x - 419;
                            int y = lockInButtonPosition.y + 191;

                            moveMouseToWithDelay(x, y, 200);

                            //Click Enter
                            Task.Delay(400).ContinueWith(_2 =>
                            {
                                MotorCortex.clickMouseAt(x, y);
                            });
                            Task.Delay(600).ContinueWith(_2 =>
                            {
                                if (pickedLane == 1)
                                {
                                    MotorCortex.typeText("T");
                                }
                                if (pickedLane == 2)
                                {
                                    MotorCortex.typeText("M");
                                }
                                if (pickedLane == 3)
                                {
                                    MotorCortex.typeText("B");
                                }
                            });
                            Task.Delay(800).ContinueWith(_2 =>
                            {
                                if (pickedLane == 1)
                                {
                                    MotorCortex.typeText("o");
                                }
                                if (pickedLane == 2)
                                {
                                    MotorCortex.typeText("i");
                                }
                                if (pickedLane == 3)
                                {
                                    MotorCortex.typeText("o");
                                }
                            });
                            Task.Delay(1000).ContinueWith(_2 =>
                            {
                                if (pickedLane == 1)
                                {
                                    MotorCortex.typeText("p");
                                }
                                if (pickedLane == 2)
                                {
                                    MotorCortex.typeText("d");
                                }
                                if (pickedLane == 3)
                                {
                                    MotorCortex.typeText("t");
                                }
                            });
                            Task.Delay(1200).ContinueWith(_2 =>
                            {
                                MotorCortex.tapEnterKey();
                            });
                        });
                    }

                    if (!VisualCortex.IsTest)
                    {
                        return;
                    }
                }
            }
            if (acceptMatchClickStopwatch.DurationInMilliseconds() >= 4000 || VisualCortex.IsTest)
            {
                acceptMatchButtonPosition = AutoQueueDetection.findImageInScreen(screen, acceptMatchButton, 366, 393, 10, 10, 0.70);
                //if (VisualCortex.IsTest) Console.WriteLine("Searching for accept button");
                //acceptMatchButtonPosition = AutoQueueDetection.findImageInScreen(screen, acceptMatchButton, 0, 0, 1024, 768, 0.5);
                if (acceptMatchButtonPosition.x != -1)
                {
                    acceptMatchClickStopwatch.Reset();
                    Console.WriteLine("\tFound accept match button at " + acceptMatchButtonPosition.x + ", " + acceptMatchButtonPosition.y);
                    if (!VisualCortex.IsTest)
                    {
                        Task.Delay(4000).ContinueWith(_2 =>
                        {
                            MotorCortex.clickMouseAt(acceptMatchButtonPosition.x + 10, acceptMatchButtonPosition.y + 10);
                            moveMouseToWithDelay(0, 0, 200);
                        });
                    }
                    if (!VisualCortex.IsTest)
                    {
                        return;
                    }
                }
            }
            if (randomChampClickStopwatch.DurationInMilliseconds() >= 6000 || VisualCortex.IsTest)
            {
                randomChampButtonPosition = AutoQueueDetection.findImageInScreen(screen, randomChampButton, 235, 186, 10, 10, 0.9);
                if (randomChampButtonPosition.x != -1)
                {
                    randomChampClickStopwatch.Reset();
                    Console.WriteLine("\tFound random champ button");
                    if (!VisualCortex.IsTest)
                    {
                        Task.Delay(1200).ContinueWith(_2 =>
                        {
                            MotorCortex.clickMouseAt(randomChampButtonPosition.x + 10, randomChampButtonPosition.y + 10);
                            moveMouseToWithDelay(0, 0, 200);
                        });

                        /*
                         * //Click Enter
                         * Task.Delay(200).ContinueWith(_ =>
                         * {
                         *  MotorCortex.typeText("{ENTER}");
                         * });
                         * Task.Delay(400).ContinueWith(_ =>
                         * {
                         *  MotorCortex.typeText("T", true);
                         * });
                         * Task.Delay(600).ContinueWith(_ =>
                         * {
                         *  MotorCortex.typeText("o", true);
                         * });
                         * Task.Delay(800).ContinueWith(_ =>
                         * {
                         *  MotorCortex.typeText("p", true);
                         * });
                         * Task.Delay(1000).ContinueWith(_ =>
                         * {
                         *  MotorCortex.typeText("{ENTER}");
                         * });
                         */
                    }
                    if (!VisualCortex.IsTest)
                    {
                        return;
                    }
                }
            }
            if (reconnectButtonClickStopwatch.DurationInMilliseconds() >= 500 || VisualCortex.IsTest)
            {
                reconnectButtonPosition = AutoQueueDetection.findImageInScreen(screen, reconnectButton, 438, 394, 10, 10, 0.95);
                if (reconnectButtonPosition.x != -1)
                {
                    reconnectButtonClickStopwatch.Reset();
                    Console.WriteLine("\tFound reconnect button");
                    if (!VisualCortex.IsTest)
                    {
                        MotorCortex.clickMouseAt(reconnectButtonPosition.x + 10, reconnectButtonPosition.y + 10);
                        moveMouseToWithDelay(0, 0, 200);
                    }
                    if (!VisualCortex.IsTest)
                    {
                        return;
                    }
                }
            }
            if ((playAgainButtonStopwatch.DurationInMilliseconds() >= 10000 && sleeping == false) || VisualCortex.IsTest)
            {
                //Console.WriteLine("Scanning for play again button");
                playAgainButtonPosition = AutoQueueDetection.findImageInScreen(screen, playAgainButton, 776, 616, 10, 10, 0.9);
                if (playAgainButtonPosition.x != -1)
                {
                    playAgainButtonStopwatch.Reset();
                    Console.WriteLine("\tFound play again button");
                    if (!VisualCortex.IsTest)
                    {
                        Task.Delay(8000).ContinueWith(_2 =>
                        {
                            MotorCortex.clickMouseAt(playAgainButtonPosition.x + 10, playAgainButtonPosition.y + 10);
                            moveMouseToWithDelay(0, 0, 500);
                        });
                    }
                    if (!VisualCortex.IsTest)
                    {
                        return;
                    }
                }
            }
        }