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); <- this line can be removed if (definition.EnemyType == "cannon_fodder") { List<Vector> _pathPoints = new List<Vector>(); _pathPoints.Add(new Vector(1400, 0, 0)); _pathPoints.Add(new Vector(0, 250, 0)); _pathPoints.Add(new Vector(-1400, 0, 0)); enemy.Path = new Path(_pathPoints, 10); } 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); <- this line can be removed if (definition.EnemyType == "cannon_fodder") { List <Vector> _pathPoints = new List <Vector>(); _pathPoints.Add(new Vector(1400, 0, 0)); _pathPoints.Add(new Vector(0, 250, 0)); _pathPoints.Add(new Vector(-1400, 0, 0)); enemy.Path = new Path(_pathPoints, 10); } else { System.Diagnostics.Debug.Assert(false, "Unknown enemy type."); } return(enemy); }