public void Update(GameTime gameTime) { ExplosionTest.Clear(); if (0 == ExplosionDict.Count) { return; } keys.Clear(); foreach (var key in ExplosionDict.Keys) { Explosion explosion = ExplosionDict[key]; if (null == explosion || !explosion.IsExploding) { continue; } // Update explosion but check to see if finished. explosion.Update(gameTime); if (!explosion.IsExploding) { ExplosionTest.Add((Byte)explosion.EnemyID); keys.Add(explosion.ID); } } // https://stackoverflow.com/questions/9892790/deleting-while-iterating-over-a-dictionary foreach (var key in keys) { ExplosionDict.Remove(key); } }
public void Clear() { ExplosionTest.Clear(); ExplosionDict.Clear(); }