//spawns a wave of a certain enemy type
    IEnumerator Spawn()
    {
        Wave wave        = waves[waveIndex];
        int  waveEnemies = 0;

        foreach (var count in wave.counts)
        {
            waveEnemies += count;
        }

        //Debug.Log("wave total enemies: " + waveEnemies + ". Should be 3");

        wave.Init();
        wave.DetermineEnemyOrder();

        //Debug.Log("wave order: " + wave.enemyOrder.ToString());

        //TODO Fix wave total enemies
        for (int i = 0; i < waveEnemies; i++)  //spawn whatever enemy has been selected
        {
            //SpawnEnemy();
            wave.SpawnNextEnemy(i);
            yield return(new WaitForSeconds(1f / wave.spawnRate));
        }

        waveIndex++;
        if (waveIndex == waves.Length)
        {
            Debug.Log("all levels passed. Congrats!");
            end.DisplayVictory();
            enabled = false;
        }
    }