void SpawnEnemies() { int possibleAmountToSpawn = currentMaxAmountEnemies - amountSpawnedEnemies; // If for some reason it didn't increase the spawned amount, set it to max if (possibleAmountToSpawn <= 0) { amountSpawnedEnemies = currentMaxAmountEnemies; return; } //Get the type of enemy we'll spawn var enemySpawnData = EnemySpawnerService.GetEnemyTypeToSpawn(currentLevelDifficult, enemySpawnerResolver); int amountEnemiesToSpawn = 0; if (possibleAmountToSpawn > enemySpawnData.enemySpawnManager.GetAmountToSpawn()) { amountEnemiesToSpawn = enemySpawnData.enemySpawnManager.GetAmountToSpawn(); } else { amountEnemiesToSpawn = GetAmountEnemiesToSpawn(possibleAmountToSpawn); } possibleAmountToSpawn -= amountEnemiesToSpawn; enemySpawnData.enemySpawnManager.IncreaseSpawnAmount(amountEnemiesToSpawn); ////if enemy == heavy, check if there's already the max in scene //if (enemyTypeToSpawn == EnemyTypeEnum.Heavy && !CanSpawnHeavyEnemy(ref amountEnemiesToSpawn)) //{ // return; //} ////if enemy == charger, check if there's already the max in scene //if (enemyTypeToSpawn == EnemyTypeEnum.Charger && !CanSpawnChargerEnemy(ref amountEnemiesToSpawn)) //{ // return; //} ////if enemy == charger, check if there's already the max in scene //if (enemyTypeToSpawn == EnemyTypeEnum.Trapper && !CanSpawnTrapperEnemy(ref amountEnemiesToSpawn)) //{ // return; //} //Get the number of the enemy type. E.g: Standard/0 or Standard/1 string enemyMaxVal = GetMaxAmountOfEnemyType(enemySpawnData.enemyType); var enemyKindVal = EnemySpawnerService.GetEnemyKind(enemySpawnData.enemyType, Convert.ToInt32(enemyMaxVal), currentLevelDifficult); //Find the enemytype category in the Hierachy. It's contained inside EnemyPool Transform enemyCategory = enemyPool.transform.Find(string.Format("{0}/{1}", enemySpawnData.enemyType.ToString(), enemyKindVal)); InstantiateEnemiesFromPool(enemyCategory, amountEnemiesToSpawn); }
private void Start() { amountEnemiesBaseLevel = EnemySpawnerService.SetInitialDifficult(timeExperienceThreshold); maxEnemiesTypes = (Enum.GetValues(typeof(EnemyTypeEnum)) as EnemyTypeEnum[]).Length - 1; currentDifficultTime = timeToChangeDifficult; currentMaxAmountEnemies = amountEnemiesBaseLevel; //These are used with the method: GetMaxAmountOfEnemyType() amountStandard = Convert.ToInt16(Resources.Load <TextAsset>("EnemyTypeCount/standard").text); amountLight = Convert.ToInt16(Resources.Load <TextAsset>("EnemyTypeCount/light").text); amountCharger = Convert.ToInt16(Resources.Load <TextAsset>("EnemyTypeCount/charger").text); amountHeavy = Convert.ToInt16(Resources.Load <TextAsset>("EnemyTypeCount/heavy").text); amountTrapper = Convert.ToInt16(Resources.Load <TextAsset>("EnemyTypeCount/trapper").text); StartCoroutine(SpawnEnemyRoutine()); }