private IEnumerator SpawnEnemiesRoutine(RedemptionTDSpawnInfo spawnInfo) { yield return(new WaitForSeconds(spawnInfo.StartSpawnDelay)); var enemies = objectPool.GetUnits(spawnInfo.EnemyType, spawnInfo.NumberToSpawn); foreach (var enemy in enemies) { var enemyMode = UnitMode.CreateUnitMode(); enemy.SpawnObject(currentSpawnCount, spawnInfo.SpawnPosition.transform.position, enemyMode); if (currentSpawnCount < currentSpawns.Count) { currentSpawns[currentSpawnCount] = enemy; } else { currentSpawns.Add(enemy); } currentSpawnCount++; enemy.ObjectReturned += HandleEnemyReturned; var movement = enemy.GetComponent <EnemyMovement>(); movement.Initialize(spawnInfo.SpawnPosition); movement.Move(); yield return(new WaitForSeconds(spawnInfo.TimeBetweenSpawns)); } yield return(new WaitForSeconds(spawnInfo.StopSpawnDelay)); }
private void SpawnWeapon(Vector2 position) { if (!ResourcesOverseer.DecreaseResourceEvent(currentWeapon.WeaponCost)) { return; } var weapons = objectPool.GetUnits(currentWeapon.WeaponType, 1); var weaponMode = UnitMode.CreateUnitMode(currentWeapon.WeaponMode); foreach (var weapon in weapons) { weapon.SpawnObject(0, position, weaponMode); } }