示例#1
0
 static PanelLocation()
 {
     Dialog = new PanelLocation()
     {
         ExternalDialog = true,
         Side = PanelSide.Any
     };
 }
示例#2
0
        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);
            }
        }
示例#3
0
 private static string GetPaneName(PanelLocation location)
 {
     switch (location)
     {
         case PanelLocation.Left:
             return "LeftPane";
         case PanelLocation.Right:
             return "RightPane";
         case PanelLocation.Bottom:
             return "BottomPane";
         default:
             return "RightPane";
     }
 }
        private void btnTradeDepotStartCapture_Click(object sender, EventArgs e)
        {
            this.btnTradeDepotStartCapture.Enabled = false;

            Random random = new Random();

            tradeWindow.StopCapture = false;

            itemHashes.ReadHashes();

            Action waitForNewImages = () =>
            {
                int n = 0;
                while (CaptureImagesGlobalTrade().Count == 0)
                {
                    n         = n + 1;
                    this.Text = "Waiting for new images (" + n + ")";
                    if (this.tradeWindow.IsRefreshGlobalTradeButtonVisible())
                    {
                        touch.ClickAt(Bot.Location.GlobalTradeRefresh);
                    }
                    WaitForSeconds(1);

                    if (n == 15)
                    {
                        touch.ClickAt(Bot.Location.GlobalTradeOk);
                        touch.ClickAt(Bot.Location.HomeButton);
                        touch.ClickAt(Bot.Location.HomeButton);
                        touch.ClickAt(Bot.Location.GlobalTrade);
                        n = 0;
                    }
                }
            };

            while (!tradeWindow.StopCapture)
            {
                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(CaptureImagesGlobalTrade());
                    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(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(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(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);
                WaitForSeconds(2);

                if (CaptureImagesGlobalTrade().Count == 0)
                {
                    touch.ClickAt(Bot.Location.HomeButton);
                }
            }

            this.btnTradeDepotStartCapture.Enabled = true;
        }