예제 #1
0
        private static void DemonStage_Enter()
        {
            int error = 0;

            while (!BotCore.RGBComparer(new Point(824, 651), Color.FromArgb(80, 1, 9), 15))
            {
                if (!BotCore.GameIsForeground("com.nubee.valkyriecrusade"))
                {
                    ScriptErrorHandler.Reset("Game close, restarting...");
                    return;
                }
                error++;
                if (error > 10)
                {
                    ScriptErrorHandler.Reset("Event Locate Failed!");
                    BotCore.KillGame("com.nubee.valkyriecrusade");
                    return;
                }
                BotCore.Delay(1000, false);
            }
            error = 0;
            Variables.ScriptLog("Demon Realm Event Located", Color.Lime);
            List <Point> BlackListedLocation = new List <Point>();

            Variables.ScriptLog("Fetching stage images", Color.White);
            List <Image> Stage = new List <Image>();

            foreach (var file in Directory.GetFiles("Img\\DemonRealm", "*.png").OrderBy(f => f))
            {
                Stage.Add(Image.FromFile(file));
            }
            Point?p = null;

            while (error < 10 && p == null)
            {
                if (!BotCore.GameIsForeground("com.nubee.valkyriecrusade"))
                {
                    return;
                }
                VCBotScript.image = Screenshot.ImageCapture();
                var crop = Screenshot.CropImage(VCBotScript.image, new Point(0, 0), new Point(1280, 615));
                Variables.ScriptLog("Trying to find stages to enter", Color.LightSkyBlue);
                Bitmap screen = Screenshot.Decompress(crop);
                foreach (var blacklist in BlackListedLocation)
                {
                    using (Graphics grf = Graphics.FromImage(screen))
                    {
                        using (Brush brsh = new SolidBrush(ColorTranslator.FromHtml("#000000")))
                        {
                            grf.FillEllipse(brsh, blacklist.X, blacklist.Y, 5, 5);
                        }
                    }
                }
                foreach (var stage in Stage)
                {
                    for (int x = 0; x < 4; x++)
                    {
                        p = BotCore.FindImage(screen, (Bitmap)stage, false, 0.8);
                        if (p != null)
                        {
                            if (!BlackListedLocation.Contains(p.Value))
                            {
                                Variables.ScriptLog("Stage found!", Color.Lime);
                                BotCore.SendTap(p.Value);
                                BotCore.Delay(3000, false);
                                bool StageEnterable = false;
                                for (int y = 0; y < 10; y++)
                                {
                                    if (BotCore.RGBComparer(new Point(543, 122), Color.FromArgb(60, 106, 137), 20))
                                    {
                                        StageEnterable = true;
                                        break;
                                    }
                                    else
                                    {
                                        BotCore.Delay(1000);
                                    }
                                }
                                if (StageEnterable)
                                {
                                    BotCore.SendTap(768, 536);
                                    BotCore.Delay(4500, false);
                                    BotCore.SendTap(970, 614);
                                    BotCore.Delay(2000, false);
                                    BotCore.SendTap(753, 423);
                                }
                                else
                                {
                                    Variables.ScriptLog("Ops, looks like the stage is not able to enter!", Color.Red);
                                    BlackListedLocation.Add(p.Value);
                                    using (Graphics grf = Graphics.FromImage(screen))
                                    {
                                        using (Brush brsh = new SolidBrush(ColorTranslator.FromHtml("#000000")))
                                        {
                                            grf.FillEllipse(brsh, p.Value.X, p.Value.Y, 5, 5);
                                        }
                                    }
                                    continue;
                                }

                                break;
                            }
                        }
                    }
                    if (p != null)
                    {
                        break;
                    }
                    else
                    {
                        p = BotCore.FindImage(screen, Img.Boss, false, 0.85);
                        if (p != null)
                        {
                            Variables.ScriptLog("Boss Stage found!", Color.Lime);
                            if (VCBotScript.runes == 3 && VCBotScript.energy != 5)
                            {
                                VCBotScript.StuckRune();
                                return;
                            }
                            BotCore.SendTap(p.Value);
                            Point?point = null;
                            BotCore.Delay(5000, false);
                            for (int x = 0; x < 20; x++)
                            {
                                VCBotScript.image = Screenshot.ImageCapture();
                                var p3 = BotCore.FindImage(VCBotScript.image, Img.GreenButton, false, 0.9);
                                if (p3 != null)
                                {
                                    BotCore.SendTap(p3.Value);
                                    BotCore.Delay(1000, false);
                                    continue;
                                }
                                if (!BotCore.GameIsForeground("com.nubee.valkyriecrusade"))
                                {
                                    return;
                                }
                                point = BotCore.FindImage(VCBotScript.image, Img.Red_Button, false, 0.9);
                                if (point != null)
                                {
                                    break;
                                }
                                BotCore.Delay(1000, false);
                            }
                            if (point == null)
                            {
                                BotCore.KillGame("com.nubee.valkyriecrusade");
                                ScriptErrorHandler.Reset("No expected UI is shown, restarting game!");
                                return;
                            }
                            BotCore.SendTap(point.Value);
                            break;
                        }
                    }
                }
                VCBotScript.image = Screenshot.ImageCapture();
                Point?p2 = BotCore.FindImage(crop, Img.GreenButton, false, 0.9);
                if (p2 != null)
                {
                    BotCore.SendTap(p2.Value);
                    BotCore.Delay(1000, false);
                    continue;
                }
                error++;
            }
            if (error > 9)
            {
                Variables.ScriptLog("Looks like we are in the trouble!", Color.Red);
                error = 0;
                BotCore.KillGame("com.nubee.valkyriecrusade");
                ScriptErrorHandler.Reset("Restarting game as unable to detect stages properly!");
            }
            PrivateVariable.Instance.Battling = true;
            VCBotScript.stop.Start();
        }
예제 #2
0
        private static void Attack()
        {
            do
            {
                BotCore.Delay(1500);
                VCBotScript.image = Screenshot.ImageCapture();
            }while (BotCore.RGBComparer(new Point(400, 400), Color.Black, 10, VCBotScript.image));
            Variables.ScriptLog("Running stage!", Color.Lime);
            int error = 0;

            do
            {
                Random rnd = new Random();
                VCBotScript.image = Screenshot.ImageCapture();
                var   crop    = Screenshot.CropImage(VCBotScript.image, new Point(420, 360), new Point(855, 450));
                Point?buttons = BotCore.FindImage(crop, Img.GreenButton, false, 0.9);
                if (buttons != null)
                {
                    ArchwitchEvent.CheckWalkEnergy();
                    if (ArchwitchEvent.CurrentWalkEnergy <= 15 || (ArchwitchEvent.CurrentBossEnergy <= 3 && ArchwitchEvent.FullBossEnergy > 0))
                    {
                        //No energy
                        Variables.ScriptLog("SoulWeapon Event have no energy. Exiting now! ", Color.Yellow);
                        TimeSpan delay = new TimeSpan(0, ((ArchwitchEvent.FullWalkEnergy - ArchwitchEvent.CurrentWalkEnergy) * 5), 0);
                        VCBotScript.nextOnline = DateTime.Now + delay;
                        Variables.ScriptLog("Estimate online time is " + VCBotScript.nextOnline, Color.Lime);
                        BotCore.KillGame(VCBotScript.game);
                        BotCore.Delay(delay);
                        PrivateVariable.Instance.InEventScreen = false;
                        PrivateVariable.Instance.InMainScreen  = false;
                        PrivateVariable.Instance.Battling      = false;
                        PrivateVariable.Instance.InMap         = false;
                        ArchwitchEvent.CurrentBossEnergy       = ArchwitchEvent.FullBossEnergy;
                        ArchwitchEvent.CurrentWalkEnergy       = ArchwitchEvent.FullWalkEnergy;
                        BotCore.StartGame(VCBotScript.game + VCBotScript.activity);
                        return;
                    }
                    BotCore.SendTap(buttons.Value.X + rnd.Next(430, 845), buttons.Value.Y + rnd.Next(370, 420));
                    BotCore.Delay(2000, 3000);
                    continue;
                }
                buttons = BotCore.FindImage(VCBotScript.image, Img.Return, true, 0.9);
                if (buttons != null)
                {
                    BotCore.SendTap(buttons.Value);
                    BotCore.Delay(1000, 1500);
                    continue;
                }
                buttons = BotCore.FindImage(VCBotScript.image, Img.Close2, true, 0.9);
                if (buttons != null)
                {
                    BotCore.SendTap(buttons.Value);
                    BotCore.Delay(1000, 1500);
                    continue;
                }
                buttons = BotCore.FindImage(crop, Img.Red_Button, false, 0.87);
                if (buttons != null)
                {
                    ArchwitchEvent.CheckBossEnergy();
                    BotCore.SendTap(buttons.Value.X + rnd.Next(430, 845), buttons.Value.Y + rnd.Next(370, 420));
                    BotCore.Delay(2000, 3000);
                    PrivateVariable.Instance.Battling = true;
                    VCBotScript.Battle();
                    continue;
                }
                buttons = BotCore.FindImage(VCBotScript.image, Img.ShopKeeper, true, 0.9);
                if (buttons != null)
                {
                    BotCore.SendTap(770, 640);
                    Variables.ScriptLog("Shop keeper found! Getting in and see what to buy!", Color.White);
                    BotCore.Delay(3000);
                    VCBotScript.image = Screenshot.ImageCapture();
                    if (BotCore.FindImage(VCBotScript.image, Img.MisteryBox, true, 0.9) != null)
                    {
                        Variables.ScriptLog("Mistory Box found! Purchasing all products!", Color.Lime);
                        BotCore.Delay(10000);
                        for (int x = 0; x < 3; x++)
                        {
                            switch (x)
                            {
                            case 0:
                                Variables.ScriptLog("Purchasing First Item", Color.Wheat);
                                BotCore.SendTap(1030, 220);
                                break;

                            case 1:
                                Variables.ScriptLog("Purchasing Second Item", Color.Wheat);
                                BotCore.SendTap(1030, 390);
                                break;

                            case 2:
                                Variables.ScriptLog("Purchasing Third Item", Color.Wheat);
                                BotCore.SendTap(1030, 550);
                                break;
                            }
                            BotCore.Delay(3000);
                            Point?greenButton;
                            do
                            {
                                BotCore.SendTap(2, 2);
                                BotCore.Delay(300);
                                VCBotScript.image = Screenshot.ImageCapture();
                                greenButton       = BotCore.FindImage(VCBotScript.image, Img.GreenButton, false, 0.9);
                            }while (greenButton == null);
                            BotCore.SendTap(greenButton.Value);
                            for (int y = 0; y < 10; y++)
                            {
                                BotCore.SendTap(2, 2);
                                BotCore.Delay(500);
                            }
                            BotCore.Delay(5000);
                        }
                    }
                    BotCore.SendTap(1110, 875);
                    BotCore.Delay(500);
                    continue;
                }
                if (BotCore.FindImage(VCBotScript.image, Img.ArchwitchHunt, true, 0.9) != null)
                {
                    //Stage completed
                    return;
                }
                error++;
                if (error > 30)
                {
                    Screenshot.Decompress(VCBotScript.image).Save("Profiles\\Logs\\error.png");
                    //UnhandledException = true;
                    Variables.ScriptLog("Unhandled exception. Contact PoH98 for fix!", Color.Red);
                    return;
                }
                else
                {
                    BotCore.Delay(1000, 1500);
                }
            }while (true);
        }