public override void Initialize() { CréerPositionsSoldats(); Flag = new Flag(Game, 1F, Vector3.Zero, new Vector3(PosFlag.X, 5, PosFlag.Z), new Vector2(1, 1), "FeuFollet", new Vector2(20, 1), 1f / 60); Game.Components.Add(Flag); CréerSoldats(); CalculerMoyennePosition(); AnciennePosition = MoyennePosition; AfficheurNbVivant = new AfficheurNb(Game, Color.Red, NbVivants, new Vector2(0, Game.Window.ClientBounds.Height - MARGE_BAS), "Nombre Soldats :", INTERVALLE_STANDARD); Game.Components.Add(AfficheurNbVivant); GestionInput = Game.Services.GetService(typeof(InputManager)) as InputManager; base.Initialize(); Caméra.SetPosCaméra(new Vector3(0, 9f, PosFlag.Z)); }
/// <summary> /// À chaque tour de boucle il vérifie l'état du niveau et appelle la classe nécessaire /// </summary> /// <param name="gameTime">le temps du jeu</param> public override void Update(GameTime gameTime) { Game.IsMouseVisible = true; Point point = GestionnaireManager.GetPositionSouris(); PosSouris = new Vector2(point.X, point.Y); if (PartieEnCours.EstRéussi) { InitialiserMenuContinuer(); } if (PartieEnCours.EstÉchec) { Vector2 PosTexte = new Vector2(Game.Window.ClientBounds.Width / 2, Game.Window.ClientBounds.Height / 2 - 150); AfficheurTexte = new AfficheurTexte(Game, Color.Red, PosTexte, "Vous avez échoué.", INTERVALLE_MOYEN); Game.Components.Add(AfficheurTexte); //Boutton Recommencer = new Boutton(Game, "Recommencer Niveau", new Rectangle(Game.Window.ClientBounds.Width / 2, Game.Window.ClientBounds.Height / 2 - 50, //LARGEUR_BOUTTON, HAUTEUR_BOUTTON), Color.Blue, "fond écran blanc", "FondEcranGris", NbSoldatsContinuer, //PartieEnCours.GetNbSections(), INTERVALLE_MOYEN); //Bouttons.Add(Recommencer); Bouttons.Add(Exit); //Bouttons.Add(Réinitialiser); //Game.Components.Add(Réinitialiser); //Game.Components.Add(Recommencer); Game.Components.Add(Exit); Afficheur = new AfficheurNb(Game, Color.Red, CompteurNiveau, new Vector2(0, 0), "Niveau :", INTERVALLE_MOYEN); Game.Components.Add(Afficheur); PartieEnCours.EstÉchec = false; } if (GestionnaireManager.EstSourisActive) { GestionBouttonsDeLaListe(); if (EstDansBoutton(Mute)) { if (GestionnaireManager.EstNouveauClicGauche()) { Mute.ChangerDeCouleur(); PartieEnCours.FaireJouerMusique(); } } } base.Update(gameTime); }
/// <summary> /// Initialise les différents boutton de difficulté /// </summary> public override void Initialize() { string son = "icone son"; string mute = "mute button"; Rectangle temp = Game.Window.ClientBounds; RectangleAffichageMute = new Rectangle(0, temp.Height - MARGE_BAS, 60, 60); Bouttons = new List <Boutton>(); DifficultéFacile = new Boutton(Game, "Facile", new Rectangle(temp.Width - MARGE_DROITE, temp.Top + MARGE_BAS, LARGEUR_BOUTTON, HAUTEUR_BOUTTON), Color.Blue, NOM_IMAGE_AVANT, NOM_IMAGE_APRÈS, MAXIMUM_NOMBRE_SOLDAT, MINIMUM_NOMBRE_SECTION, INTERVALLE_MOYEN); DifficultéMoyenne = new Boutton(Game, "Moyen", new Rectangle(temp.Width - MARGE_DROITE, temp.Top + MARGE_BAS * 3, LARGEUR_BOUTTON, HAUTEUR_BOUTTON), Color.Blue, NOM_IMAGE_AVANT, NOM_IMAGE_APRÈS, MAXIMUM_NOMBRE_SOLDAT, MINIMUM_NOMBRE_SECTION + 10, INTERVALLE_MOYEN); DifficultéDifficile = new Boutton(Game, "Difficile", new Rectangle(temp.Width - MARGE_DROITE, temp.Top + MARGE_BAS * 5, LARGEUR_BOUTTON, HAUTEUR_BOUTTON), Color.Blue, NOM_IMAGE_AVANT, NOM_IMAGE_APRÈS, MAXIMUM_NOMBRE_SOLDAT, MINIMUM_NOMBRE_SECTION + 20, INTERVALLE_MOYEN); Mute = new Boutton(Game, " ", RectangleAffichageMute, Color.White, son, mute, 0, 0, INTERVALLE_MOYEN); Exit = new Boutton(Game, "Quitter", new Rectangle(temp.Width / 2 - LARGEUR_BOUTTON / 2, temp.Height / 2 + DISTANCE_ENTRE_BOUTTON_QUITTER, LARGEUR_BOUTTON, HAUTEUR_BOUTTON), Color.Blue, NOM_IMAGE_AVANT, NOM_IMAGE_APRÈS, 0, 0, INTERVALLE_MOYEN); Bouttons.Add(DifficultéFacile); Bouttons.Add(DifficultéMoyenne); Bouttons.Add(DifficultéDifficile); foreach (Boutton b in Bouttons) { Game.Components.Add(b); } PosInitialeNiveau = new Vector3(0, 0, 0); AnciennePosSouris = PosSouris; PartieEnCours = new Jeu(Game, 0, PosInitialeNiveau, 0, INTERVALLE_MOYEN); CompteurNiveau = 0; Afficheur = new AfficheurNb(Game, Color.Red, ++CompteurNiveau, new Vector2(0, 0), "Niveau :", INTERVALLE_MOYEN); Game.Components.Add(Afficheur); Vector2 PosTexte = new Vector2(Game.Window.ClientBounds.Width / 4, Game.Window.ClientBounds.Height / 4); AfficheurTexte = new AfficheurTexte(Game, Color.Red, PosTexte, "Army Run!", INTERVALLE_MOYEN); Game.Components.Add(AfficheurTexte); NbSoldatsContinuer = 30; BouttonMute = true; base.Initialize(); }
public override void Update(GameTime gameTime) { TempsÉcoulé += (float)gameTime.ElapsedGameTime.TotalSeconds; TempsÉcoulé2 += (float)gameTime.ElapsedGameTime.TotalSeconds; TempsEcouleVerification += (float)gameTime.ElapsedGameTime.TotalSeconds; ReformerArmee(); if (TempsÉcoulé >= IntervalleMAJ) { GererClavier(); OptimiserPosition(); if (TempsÉcoulé2 >= IntervalleMAJ) { if (AnciennePosition != MoyennePosition) { DifférencePositionCaméraAvecArmée = new Vector3(0, 0, -Caméra.Position.Z + MoyennePosition.Z) / 10; AnciennePosition = MoyennePosition; DéplacerCaméra(); } TempsÉcoulé2 = 0; } TempsÉcoulé = 0; } if (TempsEcouleVerification >= INTERVALLE_VERIFICATION) { if (VerifierLesMorts()) { ReformerRang(); } } if (AfficheurNbVivant.NbAfficheur != NbVivants) { Game.Components.Remove(Game.Components.Where(x => x is AfficheurNb).ToList().Last()); AfficheurNbVivant = new AfficheurNb(Game, Color.Red, NbVivants, new Vector2(0, Game.Window.ClientBounds.Height - MARGE_BAS), "Nombre Soldats :", INTERVALLE_STANDARD); Game.Components.Add(AfficheurNbVivant); } Flag.ModifierPosition(new Vector3(PosFlag.X, 7, PosFlag.Z)); CalculerMoyennePosition(); }
/// <summary> /// Initialise le bouton menu recommencer /// </summary> void InitialiserMenuRecommencer() { Vector2 PosTexte = new Vector2(Game.Window.ClientBounds.Width / 2, Game.Window.ClientBounds.Height / 2 - 150); AfficheurTexte = new AfficheurTexte(Game, Color.Red, PosTexte, "Vous avez échoué.", INTERVALLE_MOYEN); Game.Components.Add(AfficheurTexte); CalculerNbSoldats(DIMINUTION_SOLDTAS_RECOMMENCER); Boutton Recommencer = new Boutton(Game, "Recommencer", new Rectangle(Game.Window.ClientBounds.Width / 2 - LARGEUR_BOUTTON / 2, Game.Window.ClientBounds.Height / 2 - HAUTEUR_BOUTTON / 2, LARGEUR_BOUTTON, HAUTEUR_BOUTTON), Color.Blue, NOM_IMAGE_AVANT, NOM_IMAGE_APRÈS, NbSoldatsContinuer, PartieEnCours.GetNbSections(), INTERVALLE_MOYEN); Bouttons.Add(Recommencer); Bouttons.Add(Exit); Game.Components.Add(Recommencer); Game.Components.Add(Exit); Afficheur = new AfficheurNb(Game, Color.Red, CompteurNiveau, new Vector2(0, 0), "Niveau :", INTERVALLE_MOYEN); Game.Components.Add(Afficheur); PartieEnCours.DéfinirÉtatJeu(PartieEnCours.EstRéussi, false); }
/// <summary> /// initialise menu continuer /// </summary> void InitialiserMenuContinuer() { Vector2 PosTexte = new Vector2(Game.Window.ClientBounds.Width / 2, Game.Window.ClientBounds.Height / 2 - 150); AfficheurTexte = new AfficheurTexte(Game, Color.Red, PosTexte, "Bravo! Vous avez complété le niveau " + CompteurNiveau.ToString(), INTERVALLE_MOYEN); Game.Components.Add(AfficheurTexte); Boutton Continuer = new Boutton(Game, "Continuer", new Rectangle(Game.Window.ClientBounds.Width / 2 - LARGEUR_BOUTTON / 2, Game.Window.ClientBounds.Height / 2 - HAUTEUR_BOUTTON / 2, LARGEUR_BOUTTON, HAUTEUR_BOUTTON), Color.Blue, NOM_IMAGE_AVANT, NOM_IMAGE_APRÈS, CalculerNbSoldats(AUGMENTATION_SOLDATS_NIVEAU), CalculerNbSection(), INTERVALLE_MOYEN); NbSoldatsContinuer = Continuer.NombreSoldats; Bouttons.Add(Continuer); Bouttons.Add(Exit); Game.Components.Add(Exit); Game.Components.Add(Continuer); Afficheur = new AfficheurNb(Game, Color.Red, ++CompteurNiveau, new Vector2(0, 0), "Niveau :", INTERVALLE_MOYEN); Game.Components.Add(Afficheur); PartieEnCours.DéfinirÉtatJeu(false, PartieEnCours.EstÉchec); }