예제 #1
0
        /// <summary>
        /// Détermine si la souris est dans les limites du bouton
        /// </summary>
        /// <param name="b">bouton de la liste</param>
        /// <returns>un booléen qui détermine si la souris est dans les limites du bouton</returns>
        bool EstDansBoutton(Boutton b)
        {
            bool      estDansBoutton = false;
            Rectangle temp           = b.GetDimensionBoutton();

            Point point = GestionnaireManager.GetPositionSouris();

            if (PosSouris.X >= temp.Left && PosSouris.X <= temp.Right)
            {
                if (PosSouris.Y >= temp.Top && PosSouris.Y <= temp.Bottom)
                {
                    estDansBoutton = true;
                }
            }
            return(estDansBoutton);
        }
예제 #2
0
        /// <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();
        }
예제 #3
0
        /// <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);
                }
            }
        }
예제 #4
0
        /// <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);
        }
예제 #5
0
        /// <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);
        }