IEnumerator SpawnEnemies() { while (true) { GetComponent <AudioSource>().PlayOneShot(spawnedEnemySFX); GameObject newEnemy = Instantiate(enemyToSpawn, transform.position, Quaternion.identity); newEnemy.transform.parent = transform; enemyCountUpdater.AdjustEnemyCount(1); yield return(new WaitForSeconds(secondsBetweenSpawns)); } }
private void HandleEnemyKilled() { if (deathParticleParent == null) { SetDeathParticleParent(); } AudioSource.PlayClipAtPoint(enemyDieSFX, FindObjectOfType <Camera>().transform.position, audioSource.volume); HandleDeathParticleSystem(); scoreUpdater.IncrementScore(1); enemyCountUpdater.AdjustEnemyCount(-1); Destroy(gameObject); }