private void CreateFormation(int troopsCount)
 {
     if (troopsCount > 0)
     {
         int columns = troopsCount / Mathf.FloorToInt(Mathf.Sqrt(troopsCount));
         Formation = new RectFormation(troopsCount, columns);
         Formation.CalculatePosition(Target.Position);
     }
 }
 public void UpdateTarget(Vector2 target)
 {
     if (Troops != null && Formation != null && Target != null)
     {
         Target.Position = target;
         Formation.CalculatePosition(Target.Position);
         for (int i = 0; i < Troops.Count; i++)
         {
             Troops[i].UpdatePosition(Formation.GetPositionOfTroop(i, Troops[i].Position));
         }
     }
 }
    public void SpawnEnemies(int enemiesToSpawn)
    {
        List <EnemyCreature> spawnedEnemies = new List <EnemyCreature>();
        int spawningEmissionRate            = SettingsService.GameSettings.spawningEmissionRate;

        Formation = new HordeFormation(enemiesToSpawn);
        Formation.CalculatePosition(transform.position);
        for (int i = 0; i < enemiesToSpawn; i++)
        {
            Transform trans = Instantiate <Transform>(enemyPrefab, transform.position, transform.rotation, transform);
            spawnedEnemies.Add(new EnemyCreature(trans.gameObject, Formation.GetPositionOfTroop(i, transform.position),
                                                 SettingsService.GameSettings.WeakZombi));
        }
        if (EnemiesManager.Instance != null)
        {
            EnemiesManager.Instance.AddEnemyGroup(new EnemiesGroup(spawnedEnemies, transform.position));
        }
        SoundManager.Instance.HordeSpawn();
    }