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"); } }
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); } }