Example #1
0
        public static void Idle()
        {
            Stopwatch sw = new Stopwatch();

            if (!GlobalVariables.fullArmy)
            {
                Main.Bot.WriteToOutput("~~~ Waiting for full army ~~~", GlobalVariables.OutputStates.Verified);
                while (!Barrack.CheckFullArmy(false))
                {
                    sw.Start();

                    Thread.Sleep(1000);
                    MainScreen.CheckMainScreen();

                    Thread.Sleep(1000);
                    MainScreen.ZoomOut();

                    Main.Bot.WriteToOutput("Going idle for 30 seconds...", GlobalVariables.OutputStates.Information);
                    Thread.Sleep(30000);
                    CollectResources();

                    Barrack.TrainTroops();
                    if (Barrack.CheckFullArmy(false))
                    {
                        break;
                    }

                    Thread.Sleep(1000);
                    DropTrophies();

                    Thread.Sleep(1000);
                    RequestAndDonate.DonateCC();

                    sw.Stop();

                    double   idleTime = (double)sw.ElapsedMilliseconds / 1000;
                    TimeSpan ts       = TimeSpan.FromSeconds(idleTime);

                    string output = string.Format("Time Idle: {0:D2} hours {1:D2} minutes {2:D2} seconds", ts.Hours, ts.Minutes, ts.Seconds, ts.Milliseconds);
                    Main.Bot.WriteToOutput(output, GlobalVariables.OutputStates.Verified);
                }
            }
        }
Example #2
0
        public static void Initialize()
        {
            Search.PrepareSearch();
            Thread.Sleep(1000);

            if (Search.VillageSearch())
            {
                PrepareAttack();
                Thread.Sleep(1000);

                Start(); //TODO:
                Thread.Sleep(1000);

                troopDict.Clear();
                MainScreen.ReturnHome();
                Thread.Sleep(1000);
            }
            else
            {
                Main.Bot.WriteToOutput("Timeout...");
            }
        }
Example #3
0
        /// <summary>
        /// Initializes the Bot.
        /// </summary>
        public static void Initialize(MainViewModel vm)
        {
            // Store in properties so we can access in the SubFunctions
            Bot = vm;
            Bot.ClearOutput();

            Bot.WriteToOutput(string.Format(Resources.OutputWelcomeMessage, Resources.AppName));
            Bot.WriteToOutput(Resources.OutputBotIsStarting);

            // Check if BlueStacks is running
            if (!BlueStacksHelper.IsBlueStacksRunning)
            {
                Bot.WriteToOutput(Resources.OutputBSNotFound, GlobalVariables.OutputStates.Error);

                Bot.IsExecuting = false;
                return;
            }

            if (!BlueStacksHelper.IsRunningWithRequiredDimensions)
            {
                Bot.WriteToOutput(Resources.OutputBSNotRunningWithDimensions);
                Bot.WriteToOutput(Resources.OutputBSApplyDimensionsIntoRegistry);

                if (!BlueStacksHelper.SetDimensionsIntoRegistry())
                {
                    // Woops! Something went wrong, log the error!
                    Bot.WriteToOutput(Resources.OutputBSApplyDimensionsError, GlobalVariables.OutputStates.Error);

                    Bot.IsExecuting = false;
                    return;
                }
                else
                {
                    Bot.WriteToOutput(Resources.OutputBSAppliedDimensionsIntoRegistry);
                }

                // Restart BlueStacks
                // Wait until restart and continue...

                BlueStacksHelper.ActivateBlueStacks();
            }

            CreateDirectory(GlobalVariables.LogPath);
            CreateDirectory(GlobalVariables.ScreenshotZombieAttacked);
            CreateDirectory(GlobalVariables.ScreenshotZombieSkipped);

            WriteLicense();

            // Run Everything related to the bot in the background
            var thread = new Thread(() =>
            {
                while (Bot.IsExecuting)
                {
                    FastFindWrapper.SetHWnd(BlueStacksHelper.GetBlueStacksWindowHandle(), true);

                    MainScreen.CheckMainScreen();
                    Thread.Sleep(1000);

                    MainScreen.ZoomOut();
                    Thread.Sleep(1000);

                    CoCHelper.Click(ScreenData.OpenChatBtn);
                    Thread.Sleep(1000);
                    string str = ReadText.GetString(151);
                    System.Windows.MessageBox.Show(str);

                    Village.ReArmTraps();
                    Thread.Sleep(1000);

                    Barrack.TrainTroops();
                    Thread.Sleep(1000);

                    Barrack.Boost();
                    Thread.Sleep(1000);

                    RequestAndDonate.RequestTroops();
                    Thread.Sleep(1000);

                    RequestAndDonate.DonateCC();
                    Thread.Sleep(1000);

                    Village.CollectResources();
                    Thread.Sleep(1000);

                    Village.UpgradeWalls();
                    Thread.Sleep(1000);

                    Village.Idle();
                    Thread.Sleep(1000);

                    //Attack.AttackMain();
                }
                ;
            })
            {
                IsBackground = true
            };

            thread.Start();
        }