예제 #1
0
파일: Jeu.cs 프로젝트: olilaued/PROJET_SIM
        protected override void Update(GameTime gameTime)
        {
            float tempsÉcoulé = (float)gameTime.ElapsedGameTime.TotalSeconds;

            TempsÉcouléDepuisMAJ += tempsÉcoulé;
            if (TempsÉcouléDepuisMAJ > INTERVALLE_MAJ_STANDARD)
            {
                switch (CurrentGameState)
                {
                case GameState.MenuPrincipal:

                    if (GestionInput.EstNouvelleTouche(Keys.Escape))
                    {
                        this.Exit();
                    }
                    if (B1.Clicked == true)
                    {
                        DéterminerSettings();
                        CommencerPartie();
                        VoilerBoutons(0, 2);
                        CurrentGameState = GameState.EnJeu;
                    }

                    if (B2.Clicked == true)
                    {
                        CurrentGameState = GameState.Options;
                        VoilerBoutons(0, 2);
                        AfficherBoutons(2, 5);
                    }
                    break;

                case GameState.Options:

                    if (B3.Clicked == true)
                    {
                        CurrentGameState = GameState.ClrsÉchiquier;
                        VoilerBoutons(2, 5);
                        AfficherBoutons(7, 11);
                    }
                    if (B4.Clicked == true)
                    {
                        CurrentGameState = GameState.TempsPartie;
                        VoilerBoutons(2, 5);
                        AfficherBoutons(11, 15);
                    }
                    if (B5.Clicked == true)
                    {
                        CurrentGameState = GameState.Musique;
                        VoilerBoutons(2, 5);
                        AfficherBoutons(15, 19);
                    }
                    if (GestionInput.EstNouvelleTouche(Keys.Escape))
                    {
                        CurrentGameState = GameState.MenuPrincipal;
                        VoilerBoutons(2, 5);
                        AfficherBoutons(0, 2);
                    }
                    break;

                case GameState.ClrsÉchiquier:
                    if (B8.Clicked || B9.Clicked || B10.Clicked == true || B11.Clicked == true)
                    {
                        CurrentGameState = GameState.Options;
                        VoilerBoutons(7, 11);
                        AfficherBoutons(2, 5);
                    }
                    break;

                case GameState.TempsPartie:
                    if (B12.Clicked || B13.Clicked || B14.Clicked || B15.Clicked == true)
                    {
                        CurrentGameState = GameState.Options;
                        VoilerBoutons(11, 15);
                        AfficherBoutons(2, 5);
                    }
                    break;

                case GameState.Musique:
                    if (B16.Clicked || B17.Clicked || B18.Clicked || B19.Clicked == true)
                    {
                        CurrentGameState = GameState.Options;
                        VoilerBoutons(15, 19);
                        AfficherBoutons(2, 5);
                    }
                    break;

                case GameState.EnPause:

                    if (GestionInput.EstNouvelleTouche(Keys.Escape) || B6.Clicked == true)
                    {
                        CurrentGameState = GameState.EnJeu;
                        VoilerBoutons(5, 7);
                        Components.Remove(Anand);
                    }
                    if (B7.Clicked == true)
                    {
                        VoilerBoutons(5, 7);
                        QuitterPartie();
                    }
                    break;

                case GameState.EnJeu:


                    if (PartiEnCours.PartieTerminée)
                    {
                        TempsÉcouléDepuisFinDePartie += tempsÉcoulé;
                        if (!Components.Contains(Gagnant))
                        {
                            switch (PartiEnCours.TourActuel.AutreCouleur)
                            {
                            case "White":
                                Components.Add(Gagnant = new TexteAffichable(this, "Arial", VAINQUEUR_N, Color.LightGreen, 0, 3.0f, PROFONDEUR_DEFAUT - 0.5f));
                                break;

                            case "Black":
                                Components.Add(Gagnant = new TexteAffichable(this, "Arial", VAINQUEUR_B, Color.LightGreen, 0, 3.0f, PROFONDEUR_DEFAUT - 0.5f));
                                break;
                            }
                        }

                        Afficheur3D afficheur3DTemporaire;
                        Components.Add(afficheur3DTemporaire = new Afficheur3D(this));
                        if (TempsÉcouléDepuisFinDePartie > TEMPS_FIN_DE_PARTIE)
                        {
                            QuitterPartie();
                            Components.Remove(Gagnant);
                            Components.Remove(afficheur3DTemporaire);
                            TempsÉcouléDepuisFinDePartie = 0;
                        }
                    }
                    else
                    {
                        if (GestionInput.EstNouvelleTouche(Keys.P))
                        {
                            switch (Chanson.State)
                            {
                            case SoundState.Playing:
                                Chanson.Pause();
                                break;

                            case SoundState.Paused:
                                Chanson.Resume();
                                break;
                            }
                        }
                        if (GestionInput.EstNouvelleTouche(Keys.Escape))
                        {
                            CurrentGameState     = GameState.EnPause;
                            Components.Add(Anand = new ZoneDéroulante(this, "Anand", new Rectangle(0, 0, GraphicsDevice.Viewport.Width, GraphicsDevice.Viewport.Height), INTERVALLE_MAJ_STANDARD));
                            Components.Remove(B6);
                            Components.Remove(B7);
                            Components.Add(B6);
                            Components.Add(B7);
                            AfficherBoutons(5, 7);
                        }

                        if (PartiEnCours.TourActuel.Couleur == "White" && CaméraJeu.aFiniTourner())
                        {
                            TempsRestantB = TempsRestantB - tempsÉcoulé;
                            ChangerTemps("W");
                            string temps = ((int)(TempsRestantB / 60)).ToString() + ":" + ((int)(TempsRestantB % 60)).ToString();
                            TempsB.ModifierTexte(temps);
                        }
                        else
                        {
                            if (CaméraJeu.aFiniTourner())
                            {
                                TempsRestantN = TempsRestantN - tempsÉcoulé;
                                ChangerTemps("N");
                                string temps = ((int)(TempsRestantN / 60)).ToString() + ":" + ((int)(TempsRestantN % 60)).ToString();
                                TempsN.ModifierTexte(temps);
                            }
                        }
                    }
                    break;
                }
                TempsÉcouléDepuisMAJ = 0;
            }


            base.Update(gameTime);
        }
예제 #2
0
파일: Jeu.cs 프로젝트: olilaued/PROJET_SIM
        protected override void Initialize()
        {
            CurrentGameState = GameState.MenuPrincipal;
            ListeDesBoutons  = new List <Bouton>();
            TempsDePartie    = 15 * 60;
            NomMap           = "Pub/club_map_2";
            OrigineÉchiquier = new Vector3(163.20f, 55.28f, -74.17f);



            Vector3 positionObjet = new Vector3(0, 0, 0);
            Vector3 rotationObjet = new Vector3(0, 0, 0);

            PositionCaméra = new Vector3(140.76f, 65.08f, -68.30f);
            CibleCaméra    = new Vector3(157.2f, 55.28f, -68.17f);
            OVCaméra       = new Vector3(-0.5933704f, 0.8049271f, -0.00201782f);


            CouleursÉchiquier    = new Color[3];
            CouleursÉchiquier[0] = Color.NavajoWhite;
            CouleursÉchiquier[1] = Color.Gray;
            CouleursÉchiquier[2] = Color.Aquamarine;



            GestionnaireDeFonts    = new RessourcesManager <SpriteFont>(this, "Fonts");
            GestionnaireDeTextures = new RessourcesManager <Texture2D>(this, "Textures");
            GestionnaireDeModèles  = new RessourcesManager <Model>(this, "Models");
            GestionnaireDeSons     = new RessourcesManager <SoundEffect>(this, "Sons");



            GestionInput   = new InputManager(this);
            GestionSprites = new SpriteBatch(GraphicsDevice);



            Components.Add(GestionInput);
            Components.Add(ArrièrePlanDéroulant = new ZoneDéroulante(this, "chess", new Rectangle(0, 0, Window.ClientBounds.Width, Window.ClientBounds.Height), INTERVALLE_MAJ_STANDARD));
            Components.Add(CaméraJeu            = new CaméraSubjective(this, PositionCaméra, CibleCaméra, OVCaméra, INTERVALLE_MAJ_STANDARD));



            Services.AddService(typeof(Random), new Random());
            Services.AddService(typeof(RessourcesManager <SpriteFont>), GestionnaireDeFonts);
            Services.AddService(typeof(RessourcesManager <Texture2D>), GestionnaireDeTextures);
            Services.AddService(typeof(RessourcesManager <Model>), GestionnaireDeModèles);
            Services.AddService(typeof(RessourcesManager <SoundEffect>), GestionnaireDeSons);
            Services.AddService(typeof(InputManager), GestionInput);
            Services.AddService(typeof(Caméra), CaméraJeu);
            Services.AddService(typeof(SpriteBatch), GestionSprites);



            CréerMP();
            CréerOptions();
            CréerChoixPause();
            CréerChoixClrsÉchi();
            CréerChoixTemps();
            CréerChoixMusique();



            //******************* MUSIQUE

            Chanson = GestionnaireDeSons.Find("Mozart_Lacrimosa").CreateInstance();

            base.Initialize();
        }