Example #1
0
 void Update()
 {
     if (!doorOpen)
     {
         // Check to see if the enemies are done spawning
         if (!doneSpawning)
         {
             doneSpawning = true;
             foreach (EnemySpawner es in roomSpawners)
             {
                 if (es.enemiesRemaining)
                 {
                     doneSpawning = false;
                     break;
                 }
             }
         }
         // Once enemies are done spawning, check to see if there are any live enemies in the room
         else if (enemiesAlive)
         {
             EnemyBase enemies = transform.GetComponentInChildren <EnemyBase>();
             if (enemies == null)
             {
                 enemiesAlive = false;
             }
         }
         // When all spawners are spent and all enemies are dead, open the door
         if (doneSpawning && !enemiesAlive)
         {
             GameObject.Find("PlayerManager").GetComponent <PlayerManager>().haveKey = true;
             if (roomDoor != null)
             {
                 roomDoor.ActivateTrigger(true);
             }
             doorOpen = true;
         }
     }
 }