public void Update() { while (queuedEnemies.Count > 0) { IEnemy enemy = queuedEnemies.Dequeue(); enemyList.Add(enemyID, enemy); enemyID++; enemy.AddChild(); } foreach (KeyValuePair <int, IEnemy> enemy in enemyList) { if (enemy.Value.Expired) { deletable.Add(enemy.Key); } } foreach (int index in deletable) { RemoveEnemy(index); } deletable.Clear(); enemies.Clear(); foreach (KeyValuePair <int, IEnemy> enemy in enemyList) { enemies.Add(enemy.Value); enemy.Value.Update(); } DropItemsEmptyRoom(); }
public void Add(IEnemy enemy) { // This check is necessary to ensure that enemies do not respawn if they were in the middle of their death sequence. if (!enemy.IsDead) { enemy.CurrentState.Spawn(); enemyList.Add(enemyID, enemy); enemyID++; enemy.AddChild(); } }