コード例 #1
0
        private void GoHomeIfAtAnotherCity()
        {
            while (this.tradeWindow.IsHomeButtonVisible())
            {
                for (int i = 0; i < 10; i++)
                {
                    log.Info("at another city, trying to go home " + (10 - i));

                    // we are at another city
                    touch.ClickAt(Bot.Location.HomeButton);

                    if (!this.tradeWindow.IsHomeButtonVisible())
                    {
                        break;
                    }

                    if (i == 5) // try to handle global trade dialog
                    {
                        touch.ClickAt(Bot.Location.GlobalTradeOk);
                    }
                }

                if (!this.tradeWindow.IsHomeButtonVisible())
                {
                    // wait to get home
                    log.Info("waiting for home to appear");
                    while (!this.tradeWindow.IsConfigButtonVisible())
                    {
                        BotApplication.Wait(1000);
                    }
                    BotApplication.Wait(5000);
                }
            }
        }
コード例 #2
0
        public void Swipe(Point pointdownAt, Point pointFrom, Point pointTo, int steps, bool touchUpAtTouchDownLocation)
        {
            var xStep = (pointTo.X - pointFrom.X) / steps;
            var yStep = (pointTo.Y - pointFrom.Y) / steps;

            //log.Info("Swiping from " + from.ToString() + " to " + to.ToString());
            TouchDown();
            this.MoveTo(pointdownAt);
            BotApplication.Wait(300);
            this.MoveTo(pointFrom);
            BotApplication.Wait(300);

            for (int i = 0; i < steps; i++)
            {
                pointFrom.X += xStep;
                pointFrom.Y += yStep;
                this.MoveTo(pointFrom);
            }

            if (!touchUpAtTouchDownLocation)
            {
                this.MoveTo(pointdownAt);
            }

            BotApplication.Wait(500);
            TouchUp();
            EndTouchData();
            //BotApplication.Wait(500);
        }
コード例 #3
0
 public void ClickAtAndHold(Point point, int waitms)
 {
     this.MoveTo(point);
     this.TouchDown();
     this.MoveTo(point);
     BotApplication.Wait(waitms);
     this.TouchUp();
     this.EndTouchData();
 }
コード例 #4
0
        private SaleResult PutItemOnSale(out string itemSold)
        {
            itemSold = string.Empty;

            // get images of trade boxes
            var panels = itemHashes.ProcessCaptureImages(CaptureImagesTradeDepot());

            // find an empty box
            var newSale = panels.Where(d => d.Item.ToLower().Contains("TradeDepotCreateNewSale".ToLower())).FirstOrDefault();

            if (newSale == null)
            {
                return(SaleResult.NoSpace);
            }

            // click on the box
            var clickPoint = this.tradeWindow.CalcClickPointTradeDepot(newSale);

            touch.ClickAt(clickPoint);
            Debug.WriteLine(DateTime.Now.ToShortTimeString() + " opened sale point");
            BotApplication.Wait(1000);

            // check that the create sale window is visible
            if (!tradeWindow.IsEditSaleCloseButtonVisible())
            {
                return(SaleResult.Other);
            }

            // find an item to sell from the create sale inventory
            var saleItems = this.tradePanelCapture.CaptureCreateSaleItems();
            var saleItem  = GetItemToSell(saleItems);

            if (saleItem == null)
            {
                log.Debug("Nothing to sell");
                return(SaleResult.NothingToSell);
            }

            // click on the item
            clickPoint = this.tradeWindow.CalcClickPointCreateSaleItem(saleItem);
            touch.ClickAt(clickPoint);

            // long press on the item number button
            touch.LongPress(Bot.Location.CreateSaleQuantityPlus, 3);

            // long press on the item value button
            touch.LongPress(Bot.Location.CreateSalePricePlus, 3);

            // put it on sale
            touch.ClickAt(Bot.Location.CreateSalePutOnSale);

            Debug.WriteLine(DateTime.Now.ToShortTimeString() + " Sold: " + saleItem.Item);
            log.Debug("Sold: " + saleItem.Item);

            itemSold = saleItem.Item;
            return(SaleResult.SoldItem);
        }
コード例 #5
0
        // 950 237
        public void GotoCenter()
        {
            for (var i = 0; i < 4; i++)
            {
                GotoTopLeft();
            }


            Execute("input touchscreen swipe 500 610 100 110");
            BotApplication.Wait(2 * 1000);
        }
コード例 #6
0
        public void LongPress(Location location, int seconds)
        {
            var point = Constants.GetPoint(location);

            this.TouchDown();
            this.MoveTo(point);

            BotApplication.Wait(seconds * 1000);

            this.TouchUp();
            this.EndTouchData();

            BotApplication.Wait(1000);
        }
コード例 #7
0
        public void CollectSales()
        {
            var panels = itemHashes.ProcessCaptureImages(CaptureImagesTradeDepot());

            var soldItems = panels.Where(d => d.Item.ToLower().Contains("TradeDepotSoldItem".ToLower())).ToList();

            soldItems.ForEach(sold =>
            {
                var clickPoint = this.tradeWindow.CalcClickPointTradeDepot(sold);
                touch.ClickAt(clickPoint);
                Debug.WriteLine(DateTime.Now.ToShortTimeString() + " Collected sale");
                BotApplication.Wait(1000);
            });
        }
コード例 #8
0
        public List <Bitmap> GetResourceImages(Bot.Location clickAt, List <Bot.Location> resourceLocations)
        {
            var resourceLocationOffset = Constants.GetOffset(clickAt);

            touch.TouchDown();
            touch.MoveTo(Constants.GetPoint(clickAt));

            BotApplication.Wait(300);

            var images = resourceLocations.Select(resourceLocation =>
            {
                var capturePoint = Constants.GetPoint(resourceLocation);
                return(captureScreen.SnapShot(capturePoint.X + resourceLocationOffset.X, capturePoint.Y + resourceLocationOffset.Y, new Size(70, 35)));
            }).ToList();

            touch.TouchUp();
            touch.EndTouchData();

            return(images);
        }
コード例 #9
0
 public void GotoTopLeft()
 {
     Execute("input touchscreen swipe 100 110 530 520");
     BotApplication.Wait(1 * 1000);
 }