public void Update(GameTime gameTime) { if (wave_timer > 0) { wave_timer -= gameTime.ElapsedGameTime.TotalMilliseconds; } else { /* * //Here we want to go through the instructions * if(current_element.Name == "Enemy") * { * * EnemyManager.enemyType type = enemyManager.StringToEnemyType(current_element.Element("type").Value.ToString()); * Vector2 location = new Vector2((float)Convert.ToDouble(current_element.Element("Location").Element("x").Value), (float)Convert.ToDouble(current_element.Element("Location").Element("x").Value)); * enemyManager.CreateNewEnemy(type, location); * } */ if (current_wave == waves.Count) { state = State.finished; return; } //Here we unpack the wave and create all the enemies. current_element = waves[current_wave]; foreach (XElement enemy in current_element.Elements("Enemy")) { EnemyManager.enemyType type = enemyManager.StringToEnemyType(enemy.Element("type").Value.ToString()); Vector2 location = new Vector2((float)Convert.ToDouble(enemy.Element("Location").Element("x").Value), (float)Convert.ToDouble(enemy.Element("Location").Element("y").Value)); enemyManager.CreateNewEnemy(type, location); //Returns enemy if we want to do anything with it. } //Set the wave_timer wave_timer = Convert.ToDouble(current_element.Element("wait").Value) * 1000; //And set make sure after the timer is up we move on to the next wave current_wave++; } //enemyManager.Update(gameTime); //I might not even need this. This might be able to be handled from the main loop actually }
public Enemy CreateNewEnemy(EnemyManager.enemyType type, Vector2 location) { Vector2 velocity = new Vector2(0, -5); Vector2 spawn_location = new Vector2(100, -100); //Spawn it off screen? Enemy newEnemy; switch (type) { case EnemyManager.enemyType.shooter: //newEnemy = new Enemy(textures[type], 1, 4, location, (float)(Math.PI)); newEnemy = new EnemyShooter(textures[type], 1, 4, spawn_location, (float)(Math.PI)); enemies.Add(newEnemy); break; default: newEnemy = null; break; } newEnemy.moveTo(location, 2); return(newEnemy); }