private IEnumerator SpawnEnemies()
        {
            SpawnPoint spawnPoint = FindSpawnPoint();

            for (int i = 0; i < waveSize; i++)
            {
                Vector3 spawnPointPos = spawnPoint.transform.position;

                float randomPosX = Random.Range(spawnPointPos.x - spawnPoint.size.x / 2,
                                                spawnPointPos.x + spawnPoint.size.x / 2);

                float randomPosZ = Random.Range(spawnPointPos.z - spawnPoint.size.y / 2,
                                                spawnPointPos.z + spawnPoint.size.y / 2);

                Vector3 pos = new Vector3(randomPosX, spawnPointPos.y, randomPosZ);

                GameObject enemy = ObjectPooler.instance.GetPooledObject(GetEnemyType());
                if (enemy)
                {
                    enemy.transform.position = pos;
                    SwarmerEnemy swarmerEnemy = enemy.GetComponent <SwarmerEnemy>();
                    if (swarmerEnemy)
                    {
                        aliveEnemies.Add(swarmerEnemy);
                        swarmerEnemy.OnDeath += OnDeath;
                        swarmerEnemy.target   = target;
                    }
                }
                yield return(null);
            }

            spawningEnemies = false;
        }
 private void OnDeath(SwarmerEnemy enemy)
 {
     aliveEnemies.Remove(enemy);
     enemy.OnDeath -= OnDeath;
 }