Example #1
0
        protected override void Draw(GameTime gameTime)
        {
            GraphicsDevice.Clear(Color.Black);                     //Fond noir pour le debut
            SpriteBatch.Begin();                                   //Debut du draw
            if (MenuLaunch)                                        //Si le menu est lancer
            {
                GraphicM.MainGraph(ScreenX, ScreenY, SpriteBatch); // Dessine les elements deco du MainMenu
                MainM.MainDraw(ScreenX, ScreenY, SpriteBatch);     // Dessine les elements interactifs du MainMenu
            }
            else
            {
                GraphicsDevice.Clear(Color.Blue); //Fond bleu (on ne le voit pas donc pas forcement utile)
                if (IngameM.IngameLaunched())
                {
                    IngameM.IngameDraw(ScreenX, ScreenY, SpriteBatch); // Dessine le MenuIngame
                }
                else
                {
                    SpriteBatch.End();                                                                                                                          //On arrete le draw en cours car l'on va maintenant utiliser la camera
                    SpriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, SamplerState.PointClamp, null, null, null, _camera.GetTransformation()); //On recommence le draw mais avec la camera
                    Decor.DrawDecors(SpriteBatch);                                                                                                              //Draw le decors
                    for (int i = 0; i < Enemis.Length; i++)                                                                                                     //Dessine les enemis
                    {
                        Enemis[i].Draw(SpriteBatch);
                    }
                    joueur.Draw(SpriteBatch);      // Dessine le Joueur
                    for (int i = 0; i < life; i++) // Dessine la Vie
                    {
                        SLife[i].Draw(SpriteBatch);
                    }
                    for (int i = 0; i < mana; i++) // Dessine le Mana
                    {
                        SMana[i].Draw(SpriteBatch);
                    }
                    if (life <= 0) //Dessine game over si on est plus de vie
                    {
                        SpriteBatch.Draw(GameOver.Texture, new Rectangle((int)_camera.Position.X - ScreenX / 2, (int)_camera.Position.Y - ScreenY / 2, ScreenX, ScreenY), Color.White);
                        SpriteBatch.DrawString(GameOverString, "Appuyer sur Entree pour quitter", new Vector2(_camera.Position.X - ScreenX / 4, _camera.Position.Y - 60), Color.Green);
                    }
                }
            }

            SpriteBatch.End();  //Fin
            base.Draw(gameTime);
        }
Example #2
0
        protected override void Update(GameTime gameTime)
        {
            if (Utils.Down(Keys.Enter) && (MainM.ChoiceMainMenu(MenuLaunch) == 5 || IngameM.ingameMenuPos[IngameM.ChoiceIngameMenu()] == "Quitter vers le Bureau") || (life <= 0 && Utils.Down(Keys.Enter)))
            {
                Exit(); //On quitte si on est sur quitter dans l'un des menus ou si on est sur gameover et qu'on fait entrer
            }
            if (MenuLaunch && MainM.ChoiceMainMenu(MenuLaunch) == 0 && Utils.Down(Keys.Enter))
            {
                MenuLaunch = false; // Stop le MainMenu
                Initialize();       // Initialise le Jeu
            }
            else if (Utils.Down(Keys.Enter) && IngameM.ingameMenuPos[IngameM.ChoiceIngameMenu()] == "Quitter vers le Menu Principal")
            {
                MenuLaunch = true;        // Lance le MainMenu
                IngameM.InitIngameMenu(); // Initialise le IngameMenu
                MainM.InitMainMenu();     // Initialise le MainMenu
            }

            if (MenuLaunch == false)                                         //Verifie que le menu soit fermer
            {
                joueur.Update(Decor.DecorCol, Decor.back, Enemis, gameTime); //Update le joueur
                IA.MovIA(joueur, Enemis, Decor.DecorCol, Content);           //Update l'enemis
                _camera.CameraMouvement(joueur);                             //Update la camera
            }

            if (gameTime.TotalGameTime.Seconds % 10 == 0 && mana < 200)
            {
                mana++;
            }
            if (gameTime.TotalGameTime.Seconds % 30 == 0 && life < 100)
            {
                life++;
            }


            base.Update(gameTime);
        }