IEnumerator GenerateEnemy(ObjectPooler enemyPool, AddActive addActive, GetActive getActive, int phase) { int active = 0; while (true) { if (generate) { // Determine how many enemies are currently active. active = getActive(); // Get the current phase to determine how many enemies should be generated. int max = References.global.phaseManager.phaseMultipliers[phase]; //if( max >= 3 ) // max = 3; // Generate the appropriate number of enemies. while (active < max) { CreateObject(enemyPool); active = addActive(); // Wait a short time between each generated enemy. yield return(new WaitForSeconds(0.25f)); } } // Wait 1 second before checking if more enemies should be generated. yield return(new WaitForSeconds(1)); } }
void Start() { if (generate) { // Initialize delegates. AddActive addA = AddEnemyTypeA; AddActive addB = AddEnemyTypeB; GetActive getA = GetEnemyTypeA; GetActive getB = GetEnemyTypeB; // Initialize object pools. enemyPoolA.Initialize(enemyA, 5, trans); enemyPoolB.Initialize(enemyB, 5, trans); // Start generation coroutines. StartCoroutine(GenerateEnemy(enemyPoolA, addA, getA, (int)References.GamePhases.TypeAEnemyPhase)); StartCoroutine(GenerateEnemy(enemyPoolB, addB, getB, (int)References.GamePhases.TypeBEnemyPhase)); } }
void AssertActiveFlag(GetActive getActive, SetActive setActive) { Assert.IsFalse(getActive()); setActive(true); Assert.IsTrue(getActive()); }