/// <summary> /// Met a jour l'état d'un objet /// </summary> /// <param name="gameInstance">Instance de la partie</param> /// <param name="deltaT">Temps écoulé depuis le dernier appel</param> public override void Update(Game gameInstance, double deltaT) { if (activeMissil != null && !activeMissil.IsAlive()) { this.activeMissil = null; } if (Game.game.keyPressed.Contains(Keys.Right) || Game.game.keyPressed.Contains(Keys.Left)) { handleOutOfBound(deltaT); position += determineMove(deltaT); } if (Game.game.keyPressed.Contains(Keys.Space) && activeMissil == null) { fireMissil(gameInstance); } if (remainingTimeBonus > 0) //Si un bonus est actif { remainingTimeBonus -= deltaT; } }
/// <summary> /// Tire un missile /// </summary> /// <param name="gameInstance">L'instance de la partie</param> private void fireMissil(Game gameInstance) { if (remainingTimeBonus > 0 && activeBonus == BonusType.SUPER_MISSIL) { this.activeMissil = new Missil(position + new Vecteur2D(sprite.Draw().Width / 2 - Properties.Resources.shoot1.Width / 2, 0), Teams.Player, 3); } else { this.activeMissil = new Missil(position + new Vecteur2D(sprite.Draw().Width / 2 - Properties.Resources.shoot1.Width / 2, 0), Teams.Player); } if (remainingTimeBonus > 0 && activeBonus == BonusType.MULTIPLE_SHOT) { //On ajoute deux autres missiles gameInstance.AddNewGameObject(new Missil(position + new Vecteur2D(sprite.Draw().Width / 2 - Properties.Resources.shoot1.Width / 2 - 20f, 0), Teams.Player)); gameInstance.AddNewGameObject(new Missil(position + new Vecteur2D(sprite.Draw().Width / 2 - Properties.Resources.shoot1.Width / 2 + 20f, 0), Teams.Player)); } System.Media.SoundPlayer player = new System.Media.SoundPlayer(Properties.Resources.laser); player.Play(); gameInstance.AddNewGameObject(this.activeMissil); }