// Update is called once per frame void Update() { if (enemies == 0) { StartCoroutine(battleMusic.fadeOut(musicFade)); StartCoroutine(this.playWaveEnd(musicFade, ambience)); //instantiate some next wave button that calls the spawn enemies function when clicked this.waveEnd(); } //enemyText.text = enemies.ToString(); }
public void spawnEnemies() { GameObject currentEnemy; AI collider; float angle; for (int i = 0; i < number; i++) { angle = Random.Range(0, 360); Vector3 position = new Vector3(transform.position.x - (Mathf.Cos(angle) * 5f), 12.5f, transform.position.z - (Mathf.Sin(angle) * 5f)); currentEnemy = Instantiate(enemy, position, Quaternion.identity); enemies++; collider = currentEnemy.GetComponent <AI>(); collider.increaseStats(attackSpeed, damage, health, speed); Debug.Log("looped"); } StartCoroutine(ambience.fadeOut(musicFade)); StartCoroutine(this.playWaveEnd(musicFade, battleMusic)); }