public override void Initialize() { base.Initialize(); OrientationTank = Matrix.Identity; OrientationTank *= Matrix.CreateScale(Échelle); TexteScore = new TexteCentré(Game, Score.ToString(), "Arial20", new Rectangle(Game.Window.ClientBounds.Width / 12, Game.Window.ClientBounds.Height / 10, 100, 100), Color.Red, 0f); RotationYawTour = new Vector3(-MathHelper.PiOver2, 0, MathHelper.PiOver2); RotationPitchCanon = new Vector3(-MathHelper.PiOver2, 0.02f, MathHelper.PiOver2); SphereCollision = new BoundingSphere(Position, RAYON_COLLISION); ÉchelleTour = 0.0035f; // Valeurs prédéfinies ÉchelleCanon = 0.005f; // pour assurer la ÉchelleRoues = 0.05f; // cohérence des proportions Vie = 100; }
public override void Update(GameTime gameTime) { GérerClavier(); if (Utilisateur.EstMort) { if (!Game.Components.Contains(MessageFin)) { string score = Utilisateur.Score.ToString(); MessageFin = new TexteCentré(Game, "Vous avez marqués " + score + " points", "Arial20", new Rectangle(Game.Window.ClientBounds.Width / 4, Game.Window.ClientBounds.Height / 3, Game.Window.ClientBounds.Width / 2, Game.Window.ClientBounds.Height / 8), Color.Red, 0f); ListeGameComponents.Add(MessageFin); Game.Components.Add(MessageFin); } CompteurMort++; } if (CompteurMort >= 2000) { Game.Services.RemoveService(typeof(Caméra)); List<GameComponent> ListeGameComponentsTanksDétruits = new List<GameComponent>(); Game.Components.Remove(Utilisateur.TexteScore); foreach (GameComponent gc in ListeGameComponents) { Game.Components.Remove(gc); } foreach (GameComponent gc in Game.Components) { if (gc is TankDétruit || gc is Projectile || gc is Filtre) { ListeGameComponentsTanksDétruits.Add(gc); } } foreach (GameComponent gc in ListeGameComponentsTanksDétruits) { Game.Components.Remove(gc); } GestionEnnemis.EffacerEnnemis(); MenuPrincipal.ModifyComponents(true, ListeGameComponentsMenu); } base.Update(gameTime); }
void ÉcrireInstructions() { // --- Textes à afficher --- string texteInstruction1 = "Le but est de tirer tous les tanks ennemis en évitant de se faire tirer."; string texteInstruction2 = "Contrôlez la caméra avec la souris."; string texteInstruction3 = "Contrôler les mouvements du tank avec [W,A,S,D]."; string texteInstruction4 = "Tirer des projectiles avec le clic gauche."; // ------- RessourcesManager<SpriteFont> GestionFont = Game.Services.GetService(typeof(RessourcesManager<SpriteFont>)) as RessourcesManager<SpriteFont>; SpriteFont Font = GestionFont.Find("Arial20"); DimensionPhrase = Font.MeasureString(texteInstruction1); Instruction1 = new TexteCentré(Game, texteInstruction1, "Arial20", new Rectangle(Game.Window.ClientBounds.Width / 5, 2 * Game.Window.ClientBounds.Height / 8, (int)DimensionPhrase.X, 2 * (int)DimensionPhrase.Y), Color.Black, 0.1f); DimensionPhrase = Font.MeasureString(texteInstruction2); Instruction2 = new TexteCentré(Game, texteInstruction2, "Arial20", new Rectangle(Game.Window.ClientBounds.Width / 5, 3 * Game.Window.ClientBounds.Height / 8, (int)DimensionPhrase.X, 2 * (int)DimensionPhrase.Y), Color.Black, 0.1f); DimensionPhrase = Font.MeasureString(texteInstruction3); Instruction3 = new TexteCentré(Game, texteInstruction3, "Arial20", new Rectangle(Game.Window.ClientBounds.Width / 5, 4 * Game.Window.ClientBounds.Height / 8, (int)DimensionPhrase.X, 2 * (int)DimensionPhrase.Y), Color.Black, 0.1f); DimensionPhrase = Font.MeasureString(texteInstruction4); Instruction4 = new TexteCentré(Game, texteInstruction4, "Arial20", new Rectangle(Game.Window.ClientBounds.Width / 5, 5 * Game.Window.ClientBounds.Height / 8, (int)DimensionPhrase.X, 2 * (int)DimensionPhrase.Y), Color.Black, 0.1f); Game.Components.Add(Instruction1); Game.Components.Add(Instruction2); Game.Components.Add(Instruction3); Game.Components.Add(Instruction4); }
public void InitializeComponents() { RessourcesManager<SpriteFont> GestionFont = Services.GetService(typeof(RessourcesManager<SpriteFont>)) as RessourcesManager<SpriteFont>; SpriteFont Font = GestionFont.Find("Arial20"); DimensionTitre = Font.MeasureString(TITRE); Titre = new TexteCentré(this, TITRE, "Arial20", new Rectangle(Window.ClientBounds.Width / 2 - 2 * (int)DimensionTitre.X, Window.ClientBounds.Height / 5, 4 * (int)DimensionTitre.X, 4 * (int)DimensionTitre.Y), Color.Black, 0.1f); ImageArrièrePlan = new ArrièrePlan(this, "Background Tank"); BtnJouer = new BoutonDeCommande(this, "Jouer", "Arial20", "BoutonNormal", "BoutonNormal", new Vector2(Window.ClientBounds.Width / 2, 4 * Window.ClientBounds.Height / 5f), true, new FonctionÉvénemtielle(DémarrerJeu)); BtnInstructions = new BoutonDeCommande(this, "Instructions", "Arial20", "BoutonNormal", "BoutonEnfoncé", new Vector2(Window.ClientBounds.Width / 2 - (Window.ClientBounds.Width / 4), 4 * Window.ClientBounds.Height / 5f), true, new FonctionÉvénemtielle(AfficherInstructions)); BtnOptions = new BoutonDeCommande(this, "Options", "Arial20", "BoutonNormal", "BoutonEnfoncé", new Vector2(Window.ClientBounds.Width / 2 + (Window.ClientBounds.Width / 4), 4 * Window.ClientBounds.Height / 5f), true, new FonctionÉvénemtielle(AfficherOptions)); BtnQuitter = new BoutonDeCommande(this, "Quitter", "Arial20", "BoutonNormal", "BoutonEnfoncé", new Vector2(5 * Window.ClientBounds.Width / 6, Window.ClientBounds.Height / 5f), true, new FonctionÉvénemtielle(QuitterJeu)); BtnFermerFenêtre = new BoutonDeCommande(this, " X ", "Arial20", "BoutonRougeX", "BoutonBleuX", new Vector2(9 * Window.ClientBounds.Width / 10, Window.ClientBounds.Height / 5), true, new FonctionÉvénemtielle(Retour)); }