Exemple #1
0
        public static Composite ChooseCharacterAndPressPlay(CharacterPositionDelegate characterPositionDelegate)
        {
            return(new DecoratorContinue(x => GameController.Game.IsSelectCharacterState == true,

                                         new Action(delegate(object context)
            {
                for (int i = 0; i < 6; i++)
                {
                    InputWrapper.KeyPress(Keys.Up);
                    Thread.Sleep(40);
                }
                for (int i = 1; i < characterPositionDelegate(context); i++)
                {
                    InputWrapper.KeyPress(Keys.Down);
                    Thread.Sleep(40);
                }

                Mouse.SetCursorPosAndLeftOrRightClick(playButtonRect2560x1600, 250);
                ControlTimer.Restart();
                while (ControlTimer.ElapsedMilliseconds < 6000 && GameController.Game.IsSelectCharacterState)
                {
                    Thread.Sleep(50);
                }
                if (GameController.Game.IsSelectCharacterState == false)
                {
                    return RunStatus.Success;
                }
                return RunStatus.Failure;
            })
                                         ));
        }
        static public Composite SellItems(bool sellUnidCrItems = false)
        {
            return(new Decorator(x => DoSelling(),

                                 new Sequence(
                                     new Action(delegate
            {
                InputWrapper.ResetMouseButtons();
                // InputWrapper.KeyPress(System.Windows.Forms.Keys.Escape);
                return RunStatus.Success;
            }),
                                     FindVendor(),
                                     MoveToAndOpenVendor(),
                                     OpenVendorSellScreen(),

                                     new Action(delegate
            {
                var inventory = WillBot.gameController.Game.IngameState.IngameUi.InventoryPanel[InventoryIndex.PlayerInventory];
                var invItems = inventory.VisibleInventoryItems;
                var itemsToSell = WillBot.Me.sellit.GetItemsToSell(invItems, sellUnidCrItems);
                if (itemsToSell.Count == 0)
                {
                    WillBot.Me.HasSoldItemsThisTownCycle = true;
                    InputWrapper.KeyPress(System.Windows.Forms.Keys.Escape);
                    Thread.Sleep(200);
                    if (WillBot.gameController.IngameState.IngameUi.VendorPanel.IsVisible)
                    {
                        InputWrapper.KeyPress(System.Windows.Forms.Keys.Escape);
                    }

                    return RunStatus.Success;
                }
                int latency = (int)WillBot.gameController.IngameState.CurLatency;
                Input.KeyDown(System.Windows.Forms.Keys.LControlKey);
                foreach (var item in itemsToSell)
                {
                    Mouse.SetCursorPosAndLeftOrRightClick(item.Rect, latency, randomClick: true);
                    Thread.Sleep(200);
                }

                Input.KeyUp(System.Windows.Forms.Keys.LControlKey);

                var acceptButton = WillBot.gameController.IngameState.IngameUi.VendorAcceptButton;
                //var acceptButton = WillBot.gameController.IngameState.IngameUi.SellWindow.GetChildAtIndex(3).GetChildAtIndex(5);
                Mouse.SetCursorPosAndLeftOrRightClick(acceptButton.GetClientRectCache, latency, randomClick: true);

                Thread.Sleep(900);
                if (WillBot.gameController.IngameState.IngameUi.VendorPanel.IsVisible)
                {
                    InputWrapper.KeyPress(System.Windows.Forms.Keys.Escape);
                }
                WillBot.Me.HasSoldItemsThisTownCycle = true;
                WillBot.Me.IsPlayerInventoryFull = false;
                return RunStatus.Success;
            })

                                     )));
        }