IEnumerator spawnCycle() { while (true) { /*float maxWeight = 0; * * for (int i = currentRound; i < rounds.Count; i++) * { * foreach (EnemySpawn j in rounds[i].enemies) * { * maxWeight += j.quantity; * } * } * * float chosenEnemy*/ foreach (EnemySpawn i in rounds[Random.Range(currentRound, rounds.Count)].enemies) { for (int j = 0; j < i.quantity; j++) { StartCoroutine(Spawnable.spawnEnemy(i.enemy)); } } yield return(new WaitForSeconds(Random.Range(minFrequency, maxFrequency + 0.01f))); } }
// Start is called before the first frame update void Start() { if (!hasIntroTransition) { foreach (EnemySpawn enemy in rounds[currentRound].enemies) { for (int i = 0; i < enemy.quantity; i++) { StartCoroutine(Spawnable.spawnEnemy(enemy.enemy)); } } rounds[currentRound].transition.startCheck(); if (rounds[currentRound].transition.hasTransitioned) { currentRound++; } } else { introTransition.startCheck(); if (introTransition.hasTransitioned) { hasIntroTransition = false; Start(); } } }
// Update is called once per frame void Update() { if (!hasIntroTransition) { if ((!looping && currentRound < rounds.Count - 1) || looping) { rounds[currentRound].transition.updateCheck(); if (rounds[currentRound].transition.hasTransitioned) { currentRound++; if (currentRound > rounds.Count - 1) { currentRound = 0; foreach (SpawnRound round in rounds) { round.reset(); } } foreach (EnemySpawn enemy in rounds[currentRound].enemies) { for (int i = 0; i < enemy.quantity; i++) { StartCoroutine(Spawnable.spawnEnemy(enemy.enemy)); } } rounds[currentRound].transition.startCheck(); } } } else { introTransition.updateCheck(); if (introTransition.hasTransitioned) { hasIntroTransition = false; Start(); } } }
IEnumerator spawnCycle() { if (introFrequency) { yield return(new WaitForSeconds(Random.Range(minFrequency, maxFrequency + 0.01f))); } while (true) { foreach (EnemySpawn i in rounds[Random.Range(0, rounds.Count)].enemies) { for (int j = 0; j < i.quantity; j++) { //Spawnable enemyPrefab = Instantiate(i.enemy); StartCoroutine(Spawnable.spawnEnemy(i.enemy)); } } yield return(new WaitForSeconds(Random.Range(minFrequency, maxFrequency + 0.01f))); } }