Beispiel #1
0
            public static void CollectStacks()
            {
                ResetVillageNumber();
                ZoomOutMap(1);
                ActDectFilter(MainScreen.Filters.SCOUT_FILTER);
                ImageReader reader = new ImageReader();
                List <Pair> stacks = reader.FindImageOnScreen(MainScreen.READER_AREA, "stack.bmp", 14);

                Thread.Sleep(2000);

                if (stacks.Count != 0)
                {
                    int scouts_onstack = 8 / stacks.Count;

                    foreach (var stc in stacks)
                    {
                        Controller.MoveTo(stc.X, stc.Y);
                        Thread.Sleep(100);
                        Controller.Click();
                        Controller.Click();
                        Thread.Sleep(1000);
                        SendScout(scouts_onstack);
                        ResetVillageNumber();
                        ZoomOutMap(1);
                    }
                }
                ActDectFilter(MainScreen.Filters.ERASE_FILTER);
            }
        public override void Execute()
        {
            if (!IsReady())
            {
                return;
            }

            Commands.ResetVillageNumber();
            Controller.AutoClick(MainScreen.TAB_VILLAGE);
            Controller.AutoClick(Village.TAB_TRADE);

            foreach (var x in targets)
            {
                int t_iter = 0; // Type iterator
                int r_iter = 0; // Resource iterator

                Controller.AutoClick(Trading.BUTTON_TARGETMENU);
                Controller.AutoClick(Trading.TargetMenu.targets[x]); // Select target

                Controller.AutoClick(selling_types[t_iter]);         // Select type
                Random rand = new Random();
                Controller.AutoClick(Trading.RES_1);                 //RESET
                Controller.AutoClick(Trading.RES_2);                 //RESET

                while (true)
                {
                    Controller.AutoClick(Trading.resource_list[resources[t_iter][r_iter]]);
                    var canbesold = reader.FindImageOnScreen(Trading.AREA_SELLBUTON, "sell_button.bmp", 24);
                    if (canbesold.Count == 0)
                    {
                        r_iter = (r_iter + 1) % resources[t_iter].Length;
                        if (r_iter == 0)
                        {
                            t_iter = (t_iter + 1) % resources.Count;
                            Controller.AutoClick(selling_types[t_iter]);
                        }
                        if (r_iter == 0 && t_iter == 0)
                        {
                            Commands.WriteToLog("Nothing to sell");
                            break;
                        }
                    }
                    else
                    {
                        Controller.AutoClick(Trading.BUTTON_SELL);
                        Controller.AutoClick(Trading.BUTTON_TOOFAR);
                        Commands.WriteToLog("Traders sended, Resource: " + log_dict[selling_types[t_iter]][resources[t_iter][r_iter]]);
                        Thread.Sleep(rand.Next(800, 1200));
                        break;
                    }
                }
                if (targets.Length > 1)
                {
                    Controller.AutoClick(MainScreen.NEXTVILLAGE_BUTTON);
                    Thread.Sleep(rand.Next(1800, 2300));
                }
            }
            Completed();
        }
Beispiel #3
0
        public override void Execute()
        {
            if (!IsReady())
            {
                return;
            }

            Commands.ResetVillageNumber(village);
            Commands.ZoomOutMap(1);
            Commands.ActDectFilter(FilterEnabled.Scout);

            foreach (var item in targets)
            {
                List <Pair> target = reader.FindImageOnScreen(MainScreen.READER_AREA, item, true);
                if (target.Count != 0)
                {
                    Commands.WriteToScoutLog($"{village}| Founded \"{item.Path.Substring(8, item.Path.Length - 15)}\" {target.Count}");
                    int scouts_onstack = target.Count > Available_scouts ? 1 : Available_scouts / target.Count;
                    foreach (var stc in target)
                    {
                        if (stc.X > 1000 && stc.Y > 550)
                        {
                            continue;
                        }
                        if (!AlreadySended(stc))
                        {
                            Controller.AutoClick(stc);
                            Controller.AutoClick(MainScreen.MIDDLE_OFSCREEN);
                            Commands.Scouting.SendScout(scouts_onstack);
                            sended_scouts.Add(new ScoutTarget(scouts_onstack, CountNextExecute(new Coords(stc.X, stc.Y)), DateTime.Now, stc));
                            Available_scouts -= scouts_onstack;
                            last_execute      = DateTime.Now;
                            Commands.WriteToScoutLog(village.ToString() + "| Scouts sended: " + scouts_onstack.ToString() + " Resource: " + item.Path.Substring(8, item.Path.Length - 15));

                            if (Available_scouts > 0)
                            {
                                Commands.ResetVillageNumber(village);
                                Commands.ZoomOutMap(1);
                            }
                            else
                            {
                                Completed();
                                return;
                            }
                        }
                    }
                    if (Available_scouts == 0)
                    {
                        Completed();
                        return;
                    }
                }
            }

            Commands.WriteToLog("No resources on the map");
            execute_rate_sec = 120;
            Completed();
        }
Beispiel #4
0
            public static void Attack()
            {
                ResetVillageNumber();
                ActDectFilter(MainScreen.Filters.AI_FILTER);
                ImageReader reader  = new ImageReader();
                List <Pair> castles = reader.FindImageOnScreen(MainScreen.READER_AREA, "castle_2.bmp", 20);

                Thread.Sleep(2000);

                foreach (var item in castles)
                {
                    Controller.AutoClick(item);
                    Thread.Sleep(1000);

                    List <Pair> shields = reader.FindImageOnScreen(MainScreen.READER_AREA, "shield_rat.bmp", 5);
                    List <Pair> type    = reader.FindImageOnScreen(MainScreen.READER_AREA, "castle_2_selected.bmp", 20);

                    if (shields.Count == 0 || type.Count == 0)
                    {
                        ResetVillageNumber();
                    }
                    else
                    {
                        Controller.AutoClick(AttackScreen.MAP_ATTACK_BUTTON);
                        Thread.Sleep(2000);
                        LoadFormation(AttackScreen.LocalSettings.FORM_3);
                        Controller.AutoClick(AttackScreen.SENDATTACK_BUTTON);
                        Thread.Sleep(500);
                        Controller.AutoClick(AttackScreen.SendingScreen.ATTACK_BUTTON);
                        Controller.AutoClick(AttackScreen.SendingScreen.SEND_BUTTON);
                        Thread.Sleep(2000);
                        break;
                    }
                }
                ActDectFilter(MainScreen.Filters.ERASE_FILTER);
            }
        public void ImageTest()
        {
            Thread.Sleep(2000);
            ImageReader reader = new ImageReader();
            var         time   = DateTime.Now;
            List <int>  asd    = new List <int>();

            foreach (var item in AutoScout.resdict)
            {
                var x = reader.FindImageOnScreen(MainScreen.READER_AREA, item.Value, true);
                asd.Add(x.Count);
            }

            var nstop = DateTime.Now.Subtract(time).TotalSeconds;

            var screeshot_time = ImageReader.screen_time;
            var color_list     = ImageReader.color_time;
            var find_time      = ImageReader.find_time;
        }
Beispiel #6
0
        public override void Execute()
        {
            if (!IsReady())
            {
                return;
            }
            Commands.ResetVillageNumber(village);
            Commands.ActDectFilter(FilterEnabled.AI);
            foreach (var castle in castles) // Check default types
            {
                List <Pair> exist_castles = reader.FindImageOnScreen(MainScreen.READER_AREA, castle);

                if (exist_castles.Count != 0)
                {
                    Thread.Sleep(1000);
                    foreach (var targ in exist_castles) // Check finded castles
                    {
                        Controller.AutoClick(targ);
                        Thread.Sleep(1000);

                        List <Pair> shields = new List <Pair>();
                        foreach (var shield in targets)
                        {
                            shields = reader.FindImageOnScreen(MainScreen.SELECTED_CASTLE_AREA, shields_dict[shield.Name]);
                            if (shields.Count != 0)
                            {
                                break;
                            }
                        }

                        Controller.AutoClick(MainScreen.TAB_VILLAGE);
                        Controller.AutoClick(MainScreen.TAB_MAP);
                        Thread.Sleep(2000);
                        foreach (var check in targets) // Check selected castle
                        {
                            List <Pair> type = reader.FindImageOnScreen(MainScreen.SELECTED_CASTLE_AREA, castles[check.Level]);
                            if (shields.Count != 0 && type.Count != 0)
                            {
                                Controller.AutoClick(village_pos);
                                Controller.AutoClick(AttackScreen.MAP_ATTACK_BUTTON);
                                Thread.Sleep(2000);
                                Commands.Attacking.LoadFormation(AttackScreen.LocalSettings.formations[check.Formation]);
                                Controller.AutoClick(AttackScreen.SENDATTACK_BUTTON);
                                Thread.Sleep(500);
                                Controller.AutoClick(AttackScreen.SendingScreen.ATTACK_BUTTON);
                                Controller.AutoClick(AttackScreen.SendingScreen.SEND_BUTTON);
                                CountNextExecute(new Coords(targ.X, targ.Y));
                                Commands.WriteToLog("Army sended, level: " + check.Level.ToString());
                                Thread.Sleep(2000);
                                Completed();
                                return;
                            }
                        }
                    }
                    Commands.WriteToLog("No castles to attack");
                    Commands.ResetVillageNumber(village);
                }
            }
            //execute_rate_sec = Cvrt.ToSeconds(30, 0);
            Commands.ActDectFilter(MainScreen.Filters.ERASE_FILTER);
        }