private void UpdateEnemySpawns(double gameTime) { // If no upcoming enemies then there's nothing to spawn. if (_upComingEnemies.Count == 0) { return; } EnemyDef lastElement = _upComingEnemies[_upComingEnemies.Count - 1]; if (gameTime < lastElement.LaunchTime) { _upComingEnemies.RemoveAt(_upComingEnemies.Count - 1); _enemies.Add(CreateEnemyFromDef(lastElement)); } }
private Enemy CreateEnemyFromDef(EnemyDef definition) { Enemy enemy = new Enemy(_textureManager, _effectsManager); enemy.SetPosition(definition.StartPosition); if (definition.EnemyType == "cannon_fodder") { // The enemy type could be used to alter the health or texture // but we’re using the default texture and health for the cannon fodder type } else { System.Diagnostics.Debug.Assert(false, "Unknown enemy type."); } return enemy; }
private Enemy CreateEnemyFromDef(EnemyDef definition) { Enemy enemy = new Enemy(_textureManager, _effectsManager); enemy.SetPosition(definition.StartPosition); if (definition.EnemyType == "cannon_fodder") { // The enemy type could be used to alter the health or texture // but we’re using the default texture and health for the cannon fodder type } else { System.Diagnostics.Debug.Assert(false, "Unknown enemy type."); } return(enemy); }