Пример #1
0
 public static void MoveTowards(this HommClient client, Location location, Pathfinder pathfinder)
 {
     if (location.IsEqualTo(pathfinder.HeroLocation))
     {
         client.Wait(0.2);
         return;
     }
     var path = pathfinder.FindPathTo(location);
     if (path.Count != 0)
         client.Move(path[0]);
     else
         throw new Exception("Невозможно найти путь");
 }
Пример #2
0
        // Попытка реализовать метод ThinkingWhatToDoNext блок-схемы
        public void ThinkingWhatToDoNext()
        {
            int step = 0;

            while (true)
            {
                step++;
                Console.WriteLine($"\nStep №:{step}\n");
                try
                {
                    if (sensorData.IsDead)
                    {
                        client.Wait(2);
                    }
                    // Находимся ли мы в таверне и сколько юнитов можем купить
                    int hireUnits = HireUnit(sensorData.Location);
                    // Если можем нанять хоть кого-нибудь в таверне
                    if (hireUnits != 0)
                    {
                        // Нанимаем
                        client.HireUnits(hireUnits);
                    }

                    Cell entity = new Cell();

                    entity = FindEnemy();
                    if (entity != null)
                    {
                        if (entity.X != -1 && entity.Y != -1)
                        {
                            Chain heh = AStarSolver((Cell)sensorData.Location, entity);
                            client.Move(StringToDirection(heh.path)[0]);
                            continue;
                        }
                    }

                    // Список ближайших объектов
                    Dictionary <Cell, string> nearestStuff = new Dictionary <Cell, string>();

                    // Если у нас нет золотой шахты, но есть неохраняемая шахта, добавляем ее в список на проверку
                    // Ищем шахту
                    entity = FindMine();
                    if (entity != null)
                    {
                        if (entity.X != -1 && entity.Y != -1)
                        {
                            nearestStuff.Add(entity, "Mine");
                        }
                    }

                    // Ищем таверну
                    entity = FindSecurityDwelling();

                    if (entity != null)
                    {
                        if (entity.X != -1 && entity.Y != -1)
                        {
                            nearestStuff.Add(entity, "Dwelling");
                        }
                    }

                    // Ищем ресурс
                    entity = FindResource();

                    if (entity != null)
                    {
                        if (entity.X != -1 && entity.Y != -1)
                        {
                            nearestStuff.Add(entity, "Resource");
                        }
                    }
                    // Если список не пустой
                    if (nearestStuff.Count() != 0)
                    {
                        Chain heh = FindNearest(nearestStuff.Keys.ToList());
                        client.Move(StringToDirection(heh.path)[0]);
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex);
                }
            }
        }
Пример #3
0
 public void Invoke()
 {
     client.Wait(1);
 }