private void BuyItemsFromGlobalTrade()
        {
            waitForNewImages();

            PanelLocation desirableItem = ScanGlobalForDesiredItems();

            // refresh if no desired item
            if (desirableItem == null && this.tradeWindow.IsRefreshGlobalTradeButtonVisible())
            {
                touch.ClickAt(Bot.Location.GlobalTradeRefresh);
                WaitForSeconds(1);
                waitForNewImages();
                desirableItem = ScanGlobalForDesiredItems();
            }

            if (desirableItem != null)
            {
                var clickPoint = this.tradeWindow.CalcClickPointGlobalTrade(desirableItem);
                touch.ClickAt(clickPoint);
            }
            else
            {
                // click random panel
                var globalPanels = itemHashes.ProcessCaptureImages(tradePanelCapture.CaptureImagesGlobalTrade());
                if (globalPanels.Count > 0)
                {
                    var clickPoint = this.tradeWindow.CalcClickPointGlobalTrade(globalPanels[random.Next(globalPanels.Count())]);
                    touch.ClickAt(clickPoint);
                }
            }
            WaitForSeconds(1);

            // wait for items to appear
            WaitFor(this.tradeWindow.IsTradeDepotLogoVisible, "Trade Logo");
            WaitForSeconds(1);
            SleepUntilTradeDepotItemsAreVisible(30);
            var panels = itemHashes.ProcessCaptureImages(tradePanelCapture.CaptureImagesTradeDepot());

            BuyTradeDepotItems(panels);

            if (panels.Count() > 7)
            {
                // swipe
                touch.Swipe(Bot.Location.GlobalTradeMiddleRight, Bot.Location.GlobalTradeMiddleRight, Bot.Location.GlobalTradeMiddleLeft, swipeSteps, true);
                WaitForSeconds(1);
                panels = itemHashes.ProcessCaptureImages(tradePanelCapture.CaptureImagesTradeDepot());
                BuyTradeDepotItems(panels);
            }

            if (panels.Count() > 7)
            {
                touch.Swipe(Bot.Location.GlobalTradeMiddleRight, Bot.Location.GlobalTradeMiddleRight, Bot.Location.GlobalTradeMiddleLeft, swipeSteps, true);
                WaitForSeconds(1);
                panels = itemHashes.ProcessCaptureImages(tradePanelCapture.CaptureImagesTradeDepot());
                BuyTradeDepotItems(panels);
            }

            // Click home button
            WaitForSeconds(1);

            int nn = 0;

            while (this.tradeWindow.IsTradeDepotLogoVisible())
            {
                nn++;
                touch.ClickAt(Bot.Location.GlobalTradeOtherCity);
                if (nn == 60)
                {
                    touch.ClickAt(Bot.Location.GlobalTradeOk);
                    nn = 0;
                }
            }
            touch.ClickAt(Bot.Location.GlobalTradeOtherCity);

            if (this.tradeWindow.IsOfflineButtonVisible())
            {
                // close it
                touch.ClickAt(Bot.Location.GlobalTradeOk);
            }

            WaitForSeconds(2);

            if (tradePanelCapture.CaptureImagesGlobalTrade().Count == 0)
            {
                touch.ClickAt(Bot.Location.HomeButton);
            }
        }
Exemple #2
0
 private void leftClick_Click(object sender, EventArgs e)
 {
     touch.ClickAt(Bot.Location.LeftButton);
 }
Exemple #3
0
        public void CheckReadyFactoryItemAndCollect(int n)
        {
            int x      = 358 + 142 * n;
            int y      = 675;
            int status = touch.CheckFactorySlotStatus(x, y);


            if (status == 1)                    //ready
            {
                touch.ClickAt(new Point(x, y)); //collect
                Bot.BotApplication.Wait(250);
                if (n % 5 == 0)
                {
                    touch.Swipe(Constants.GetPoint(Bot.Location.ButtonLeftInner1), Constants.GetPoint(Bot.Location.CentreMap)); // procedure
                }
                if (n % 5 == 1)
                {
                    touch.Swipe(Constants.GetPoint(Bot.Location.ButtonRightInner1), Constants.GetPoint(Bot.Location.CentreMap)); // procedure
                }
                if (n % 5 == 2)
                {
                    touch.Swipe(Constants.GetPoint(Bot.Location.ButtonLeftInner3), Constants.GetPoint(Bot.Location.CentreMap)); // procedure
                }
                if (n % 5 == 3)
                {
                    touch.Swipe(Constants.GetPoint(Bot.Location.ButtonRightInner2), Constants.GetPoint(Bot.Location.CentreMap)); // procedure
                }
                else
                {
                    touch.Swipe(Constants.GetPoint(Bot.Location.ButtonLeftInner2), Constants.GetPoint(Bot.Location.CentreMap)); // procedure
                }
            }
            if (status == 0)                                                                                                //empty
            {
                touch.Swipe(Constants.GetPoint(Bot.Location.ButtonLeftInner3), Constants.GetPoint(Bot.Location.CentreMap)); // procedure
            }
            if (status == -1)                                                                                               //processing
            {
                // donothing
                // touch.Swipe(Constants.GetPoint(Bot.Location.ButtonLeftInner2), Constants.GetPoint(Bot.Location.CentreMap)); // procedure
            }
        }
        private void btnStartCapture_Click(object sender, EventArgs e)
        {
            this.tradeWindow.StopCapture = false;

            itemHashes.ReadHashes();

            while (!this.tradeWindow.StopCapture)
            {
                touch.ClickAt(Bot.Location.GlobalTradeRefresh);
                WaitForSeconds(1);

                while (CaptureImagesGlobalTrade().Count == 0)
                {
                    this.Text = "Waiting for new images";
                    touch.ClickAt(Bot.Location.GlobalTradeRefresh);
                    WaitForSeconds(1);
                }

                var panels = itemHashes.ProcessCaptureImages(CaptureImagesGlobalTrade());
                buyIfMatchFound(panels);

                touch.Swipe(Bot.Location.GlobalTradeMiddleRight, Bot.Location.GlobalTradeMiddleRight, Bot.Location.GlobalTradeMiddleLeft, swipeSteps, true);
                WaitForSeconds(1);

                panels = itemHashes.ProcessCaptureImages(CaptureImagesGlobalTrade());
                buyIfMatchFound(panels);

                touch.Swipe(Bot.Location.GlobalTradeMiddleRight, Bot.Location.GlobalTradeMiddleRight, Bot.Location.GlobalTradeMiddleLeft, swipeSteps, true);
                WaitForSeconds(1);

                panels = itemHashes.ProcessCaptureImages(CaptureImagesGlobalTrade());
                buyIfMatchFound(panels);
                WaitForSeconds(1);

                WaitFor(this.tradeWindow.IsRefreshGlobalTradeButtonVisible, "Reset Button");
            }
        }