Exemple #1
0
        /// <summary>
        /// Manually locates the Elixir Collectors.
        /// </summary>
        public void LocateCollectors()
        {
            IsBusy = true;

            var msgBox = GetService <IMessageBoxService>();

            if (msgBox != null)
            {
                if (msgBox.Show("Do you want to start locating the Collectors, Mines and Drills?", "Locate Extractors Manually", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.No)
                {
                    return;
                }

                var p = BlueStacksHelper.GetClickPosition(2000);
                if (p.IsEmpty)
                {
                    return;
                }

                msgBox.Show(string.Format("You clicked on X={0}, Y={1}. Please test those coords with BlueStacksHelper.Click() method.", p.X, p.Y), "Location Test", MessageBoxButton.OK, MessageBoxImage.Information);

                // TODO: This is a fixed number, use a GlobalVariables so is consistent between all code (Total Collectors = 17)

                /*
                 * for (int i = 1; i < 18; i++)
                 * {
                 *      if (msgBox.Show(string.Format("Click OK, then click on your resource extractor # {0}. Press Cancel to abort the process.", i), string.Format("Locate resource extractor # {0}", i), MessageBoxButton.OKCancel, MessageBoxImage.Information) == MessageBoxResult.Cancel)
                 *              break;
                 *
                 *      var p = BlueStacksHelper.GetClickPosition(2000);
                 *      if (p.IsEmpty) continue;
                 *
                 *      string message = string.Format("Resource Extractor # {0} have the following {1},{2} coords.", i, p.X, p.Y);
                 *      System.Diagnostics.Debug.WriteLine(message);
                 *
                 *      GlobalVariables.Log.WriteToLog(message);
                 * }
                 */
            }
        }
Exemple #2
0
 public void LaunchBlueStacksAndWaitText()
 {
     using (Chrono chrono = new Chrono("LaunchBlueStacksAndWait"))
         chrono.Success = BlueStacksHelper.StartClashOfClanAndWait();
 }
Exemple #3
0
 IntPtr ICocBot.GetCOCWindow()
 {
     return(BlueStacksHelper.GetBlueStacksWindowHandle());
 }
Exemple #4
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();
        }