コード例 #1
0
ファイル: Menu.cs プロジェクト: MichaudStephane/ArmyRunTest
        /// <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);
        }
コード例 #2
0
ファイル: Menu.cs プロジェクト: MichaudStephane/ArmyRunTest
        /// <summary>
        /// Gère les boutons de la liste en fonction de la position et du clic de la souris
        /// </summary>
        void GestionBouttonsDeLaListe()
        {
            for (int i = 0; i < Bouttons.Count; i++)
            {
                Boutton b = Bouttons[i];
                if (EstDansBoutton(b))
                {
                    b.ChangerDeCouleur(true);
                    if (GestionnaireManager.EstNouveauClicGauche())
                    {
                        if (Game.Components.Where(x => x is Jeu).ToList().Count != 0)
                        {
                            Game.Components.Remove(Game.Components.Where(x => x is Jeu).ToList().First());
                            Game.Services.RemoveService(typeof(Jeu));
                        }
                        if (b != Exit)
                        {
                            Game.Components.Remove(Game.Components.Where(x => x is AfficheurTexte).ToList().First());
                            b.CréerJeu();
                            if (BouttonMute)
                            {
                                Game.Components.Add(Mute);
                                BouttonMute = false;
                            }
                        }
                        else
                        {
                            Game.Exit();
                        }
                        PartieEnCours = Game.Services.GetService(typeof(Jeu)) as Jeu;

                        foreach (Boutton boutton in Bouttons)
                        {
                            Game.Components.Remove(boutton);
                            boutton.Enabled = false;
                        }
                        Bouttons.Clear();
                    }
                }
                else
                {
                    b.ChangerDeCouleur(false);
                }
            }
        }
コード例 #3
0
ファイル: Menu.cs プロジェクト: MichaudStephane/ArmyRunTest
        /// <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);
        }
コード例 #4
0
ファイル: Menu.cs プロジェクト: MichaudStephane/ArmyRunTest
        /// <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);
        }