Exemple #1
0
        protected override void Update(GameTime gameTime)
        {
            if (button_timer < 20)
            {
                button_timer++;
            }

            if (Keyboard.GetState().IsKeyDown(Keys.Escape))
            {
                if (ecran == Screen.jeu)
                {
                    ecran    = Screen.menu_pause;
                    menuMain = new Menu(Menu.MenuType.PauseMenu);
                    PlayMusic(MenuMusic);
                }
                else if (ecran == Screen.menu_principal)
                {
                    Exit();
                }
            }

            if (ecran == Screen.menu_principal)
            {
                int action = 0;

                if (button_timer == 20)
                {
                    action = menuMain.Update(Mouse.GetState(), Keyboard.GetState());
                }
                if (action == 1)
                {
                    ecran        = Screen.multioupas;
                    menuMain     = new Menu(Menu.MenuType.MultiOrNot);
                    button_timer = 0;
                }
                if (action == 2)
                {
                    ecran        = Screen.menu_parametres;
                    menuMain     = new Menu(Menu.MenuType.MenuGeneralSettings);
                    button_timer = 0;
                }
                if (action == 3)
                {
                    Exit();
                }
            }

            else if (ecran == Screen.multioupas)
            {
                int action = 0;

                if (button_timer == 20)
                {
                    action = menuMain.Update(Mouse.GetState(), Keyboard.GetState());
                }
                if (action == 1)
                {
                    joueur       = 0;
                    multi        = false;
                    ecran        = Screen.selecteur_map;
                    menuMain     = new Menu(Menu.MenuType.MapSelector);
                    button_timer = 0;
                }
                if (action == 2)
                {
                    joueur   = 1;
                    multi    = true;
                    ecran    = Screen.connection;
                    menuMain = new Menu(Menu.MenuType.Connection);

                    button_timer = 0;
                }
                if (action == 3)
                {
                    joueur   = 2;
                    multi    = true;
                    ecran    = Screen.connection;
                    menuMain = new Menu(Menu.MenuType.Connection);

                    button_timer = 0;
                }
                if (action == 4)
                {
                    ecran        = Screen.menu_principal;
                    menuMain     = new Menu(Menu.MenuType.MainMenu);
                    button_timer = 0;
                }
            }


            else if (ecran == Screen.selecteur_map)
            {
                int action = 0;
                compteur_delai++;

                if (compteur_delai > 20)
                {
                    compteur_delai = 20;
                }
                if (button_timer == 20)
                {
                    action = menuMain.Update(Mouse.GetState(), Keyboard.GetState());
                }
                if (action == 1 && compteur_delai >= 20)
                {
                    compteur_delai       = 0;
                    compteur_thumbnails -= 1;
                    if (compteur_thumbnails < 0)
                    {
                        compteur_thumbnails = 5;
                    }
                }
                if (action == 2 && compteur_delai >= 20)
                {
                    compteur_delai       = 0;
                    compteur_thumbnails += 1;
                    if (compteur_thumbnails > 5)
                    {
                        compteur_thumbnails = 0;
                    }
                }
                if (action == 3)
                {
                    if (compteur_thumbnails == 0)
                    {
                        Main          = new GameMain();
                        Main.MainMap  = new Map(LecteurMap.lecture("map01.txt"), multi, joueur, IPMulti, 1, 0);
                        path_map      = "map01.txt";
                        GamePlayMusic = Ressources.GamePlayMusic;
                    }
                    else if (compteur_thumbnails == 1)
                    {
                        Main          = new GameMain();
                        Main.MainMap  = new Map(LecteurMap.lecture("map02.txt"), multi, joueur, IPMulti, 1, 0);
                        path_map      = "map02.txt";
                        GamePlayMusic = Ressources.GamePlayMusic;
                    }
                    else if (compteur_thumbnails == 2)
                    {
                        Main          = new GameMain();
                        Main.MainMap  = new Map(LecteurMap.lecture("map03.txt"), multi, joueur, IPMulti, 1, 0);
                        path_map      = "map03.txt";
                        GamePlayMusic = Ressources.GamePlayMusic;
                    }
                    else if (compteur_thumbnails == 3)
                    {
                        Main          = new GameMain();
                        Main.MainMap  = new Map(LecteurMap.lecture("map03_bonus.txt"), multi, joueur, IPMulti, 1, 0);
                        path_map      = "map04.txt";
                        GamePlayMusic = Ressources.GamePlayMusic;
                    }
                    else if (compteur_thumbnails == 4)
                    {
                        Main          = new GameMain();
                        Main.MainMap  = new Map(LecteurMap.lecture("map04.txt"), multi, joueur, IPMulti, 1, 0);
                        path_map      = "map04.txt";
                        GamePlayMusic = Ressources.HightVoltage;
                    }
                    else if (compteur_thumbnails == 5)
                    {
                        Main          = new GameMain();
                        Main.MainMap  = new Map(LecteurMap.lecture("map05.txt"), multi, joueur, IPMulti, 1, 0);
                        path_map      = "map05.txt";
                        GamePlayMusic = Ressources.BlackIce;
                    }
                    ecran = Screen.jeu;
                    PlayMusic(GamePlayMusic);
                    button_timer = 0;
                }
                if (action == 4)
                {
                    ecran        = Screen.multioupas;
                    menuMain     = new Menu(Menu.MenuType.MultiOrNot);
                    button_timer = 0;
                }
                if (action == 5)
                {
                }
            }

            else if (ecran == Screen.lobby)
            {
                lobby.Update(Keyboard.GetState(), oldKeyboard);
                int action = 0;
                compteur_delai++;

                if (compteur_delai > 20)
                {
                    compteur_delai = 20;
                }
                if (button_timer == 20)
                {
                    action = menuMain.Update(Mouse.GetState(), Keyboard.GetState());
                }
                if (action == 1 && compteur_delai >= 20)
                {
                    compteur_delai       = 0;
                    compteur_thumbnails -= 1;
                    if (compteur_thumbnails < 0)
                    {
                        compteur_thumbnails = 5;
                    }
                }
                if (action == 2 && compteur_delai >= 20)
                {
                    compteur_delai       = 0;
                    compteur_thumbnails += 1;
                    if (compteur_thumbnails > 5)
                    {
                        compteur_thumbnails = 0;
                    }
                }
                if (action == 3 && compteur_delai >= 20)
                {
                    Lobby_ready = !Lobby_ready;
                }


                if (action == 4)
                {
                    ecran        = Screen.multioupas;
                    menuMain     = new Menu(Menu.MenuType.MultiOrNot);
                    button_timer = 0;
                }

                if (Lobby_ready)
                {
                    lobby.Envoie(action == 5, compteur_thumbnails, 1, ref lobby.connection);
                }
                else
                {
                    lobby.Envoie(action == 5, compteur_thumbnails, 0, ref lobby.connection);
                }

                if (lobby.Reception())
                {
                    {
                        if (compteur_thumbnails == 0)
                        {
                            Main          = new GameMain();
                            Main.MainMap  = new Map(LecteurMap.lecture("map01.txt"), multi, joueur, IPMulti, lobby.nb_joueur, lobby.id_joueur);
                            path_map      = "map01.txt";
                            GamePlayMusic = Ressources.GamePlayMusic;
                        }
                        else if (compteur_thumbnails == 1)
                        {
                            Main          = new GameMain();
                            Main.MainMap  = new Map(LecteurMap.lecture("map02.txt"), multi, joueur, IPMulti, lobby.nb_joueur, lobby.id_joueur);
                            path_map      = "map02.txt";
                            GamePlayMusic = Ressources.GamePlayMusic;
                        }
                        else if (compteur_thumbnails == 2)
                        {
                            Main          = new GameMain();
                            Main.MainMap  = new Map(LecteurMap.lecture("map03.txt"), multi, joueur, IPMulti, lobby.nb_joueur, lobby.id_joueur);
                            path_map      = "map03.txt";
                            GamePlayMusic = Ressources.GamePlayMusic;
                        }
                        else if (compteur_thumbnails == 3)
                        {
                            Main          = new GameMain();
                            Main.MainMap  = new Map(LecteurMap.lecture("map03_bonus.txt"), multi, joueur, IPMulti, lobby.nb_joueur, lobby.id_joueur);
                            path_map      = "map04.txt";
                            GamePlayMusic = Ressources.GamePlayMusic;
                        }
                        else if (compteur_thumbnails == 4)
                        {
                            Main          = new GameMain();
                            Main.MainMap  = new Map(LecteurMap.lecture("map04.txt"), multi, joueur, IPMulti, lobby.nb_joueur, lobby.id_joueur);
                            path_map      = "map04.txt";
                            GamePlayMusic = Ressources.HightVoltage;
                        }
                        else if (compteur_thumbnails == 5)
                        {
                            Main          = new GameMain();
                            Main.MainMap  = new Map(LecteurMap.lecture("map05.txt"), multi, joueur, IPMulti, lobby.nb_joueur, lobby.id_joueur);
                            path_map      = "map05.txt";
                            GamePlayMusic = Ressources.BlackIce;
                        }
                        ecran = Screen.jeu;
                        PlayMusic(GamePlayMusic);
                        button_timer = 0;
                    }
                }
            }

            else if (ecran == Screen.menu_pause)
            {
                int action = 0;

                if (button_timer == 20)
                {
                    action = menuMain.Update(Mouse.GetState(), Keyboard.GetState());
                }
                if (action == 1)
                {
                    ecran        = Screen.jeu;
                    button_timer = 0;
                    PlayMusic(GamePlayMusic);
                }
                if (action == 2)
                {
                    ecran        = Screen.menu_preferences;
                    menuMain     = new Menu(Menu.MenuType.MenuPreferences);
                    button_timer = 0;
                }
                if (action == 3)
                {
                    ecran        = Screen.menu_principal;
                    menuMain     = new Menu(Menu.MenuType.MainMenu);
                    button_timer = 0;
                    StopMusic(MenuMusic);
                }
            }

            else if (ecran == Screen.menu_preferences)
            {
                int action = 0;

                if (button_timer == 20)
                {
                    action = menuMain.Update(Mouse.GetState(), Keyboard.GetState());
                }
                if (action == 1)
                {
                    MenuButton.language = "French";
                    menuMain            = new Menu(Menu.MenuType.MenuPreferences);
                    button_timer        = 0;
                }
                if (action == 2)
                {
                    MenuButton.language = "English";
                    menuMain            = new Menu(Menu.MenuType.MenuPreferences);
                    button_timer        = 0;
                }
                if (action == 3)
                {
                    MediaPlayer.Volume -= 0.1f;
                    button_timer        = 0;
                }
                if (action == 4)
                {
                    MediaPlayer.Volume += 0.1f;
                    button_timer        = 0;
                }
                if (action == 5)
                {
                    MediaPlayer.Volume = 0;
                    button_timer       = 0;
                }
                if (action == 6)
                {
                    ecran        = Screen.menu_pause;
                    menuMain     = new Menu(Menu.MenuType.PauseMenu);
                    button_timer = 0;
                }
            }

            else if (ecran == Screen.menu_parametres)
            {
                int action = 0;

                if (button_timer == 20)
                {
                    action = menuMain.Update(Mouse.GetState(), Keyboard.GetState());
                }
                if (action == 1)
                {
                    MenuButton.language = "French";
                    menuMain            = new Menu(Menu.MenuType.MenuGeneralSettings);
                    button_timer        = 0;
                }
                if (action == 2)
                {
                    MenuButton.language = "English";
                    menuMain            = new Menu(Menu.MenuType.MenuGeneralSettings);
                    button_timer        = 0;
                }
                if (action == 3)
                {
                    MediaPlayer.Volume -= 0.1f;
                    button_timer        = 0;
                }
                if (action == 4)
                {
                    MediaPlayer.Volume += 0.1f;
                    button_timer        = 0;
                }
                if (action == 5)
                {
                    MediaPlayer.Volume = 0;
                    button_timer       = 0;
                }
                if (action == 6)
                {
                    ecran        = Screen.menu_principal;
                    menuMain     = new Menu(Menu.MenuType.MainMenu);
                    button_timer = 0;
                }
                if (action == 7 && graphics.IsFullScreen == false)
                {
                    graphics.ToggleFullScreen();
                    button_timer = 0;
                }
                if (action == 8 && graphics.IsFullScreen == true)
                {
                    graphics.ToggleFullScreen();
                    button_timer = 0;
                }
                if (action == 9)
                {
                    ecran    = Screen.credits;
                    menuMain = new Menu(Menu.MenuType.Credits);
                }
            }

            else if (ecran == Screen.credits)
            {
                int action = 0;

                if (button_timer == 20)
                {
                    action = menuMain.Update(Mouse.GetState(), Keyboard.GetState());
                }
                if (action == 1)
                {
                    ecran        = Screen.menu_parametres;
                    menuMain     = new Menu(Menu.MenuType.MenuGeneralSettings);
                    button_timer = 0;
                }
            }

            else if (ecran == Screen.jeu)
            {
                Main.Update(Mouse.GetState(), Keyboard.GetState(), gameTime, graphics.GraphicsDevice);

                if (Main.MainMap.game_over)
                {
                    ecran    = Screen.game_over;
                    menuMain = new Menu(Menu.MenuType.GameOver);
                    StopMusic(GamePlayMusic);
                    loseEffect.Play();
                }
                if (Main.MainMap.fin_niveau.est_arrivee || Main.MainMap.gagne)
                {
                    ecran    = Screen.win;
                    menuMain = new Menu(Menu.MenuType.WinScreen);
                    StopMusic(GamePlayMusic);
                    winEffect.Play();
                }
                if (Main.MainMap.boss_entry.combat_boss)
                {
                    Main          = new GameMain();
                    Main.MainMap  = new Map(LecteurMap.lecture("map04.txt"), multi, joueur, IPMulti, 1, 0);
                    path_map      = "map04.txt";
                    ecran         = Screen.jeu;
                    GamePlayMusic = Ressources.HightVoltage;
                    PlayMusic(GamePlayMusic);
                    button_timer = 0;
                }
                if (!Main.MainMap.connection)
                {
                    ecran    = Screen.deconnexion;
                    menuMain = new Menu(Menu.MenuType.Deconnexion);
                    StopMusic(GamePlayMusic);
                }
            }

            else if (ecran == Screen.game_over)
            {
                int action = 0;

                if (button_timer == 20)
                {
                    action = menuMain.Update(Mouse.GetState(), Keyboard.GetState());
                }
                if (action == 1)
                {
                    ecran        = Screen.selecteur_map;
                    menuMain     = new Menu(Menu.MenuType.MapSelector);
                    button_timer = 0;
                }
            }

            else if (ecran == Screen.win)
            {
                int action = 0;

                if (button_timer == 20)
                {
                    action = menuMain.Update(Mouse.GetState(), Keyboard.GetState());
                }
                if (action == 1)
                {
                    ecran        = Screen.selecteur_map;
                    menuMain     = new Menu(Menu.MenuType.MapSelector);
                    button_timer = 0;
                }
            }

            else if (ecran == Screen.deconnexion)
            {
                int action = 0;

                if (button_timer == 20)
                {
                    action = menuMain.Update(Mouse.GetState(), Keyboard.GetState());
                }
                if (action == 1)
                {
                    ecran        = Screen.menu_principal;
                    menuMain     = new Menu(Menu.MenuType.MainMenu);
                    button_timer = 0;
                }
            }

            else if (ecran == Screen.connection)
            {
                Lobby_ready = false;
                int action = 0;
                IP_.Update(Keyboard.GetState(), oldKeyboard);
                if (button_timer == 20)
                {
                    action = menuMain.Update(Mouse.GetState(), Keyboard.GetState());
                }
                if (action == 1)
                {
                    try
                    {
                        IPMulti      = IPAddress.Parse(IP_.input);
                        ecran        = Screen.selecteur_map;
                        menuMain     = new Menu(Menu.MenuType.Lobby);
                        ecran        = Screen.lobby;
                        lobby        = new Lobby(IPMulti);
                        button_timer = 0;
                    }
                    catch
                    {
                        IP_.input = "Mauvaise IP";
                    }
                }
            }

            oldKeyboard = Keyboard.GetState();
            base.Update(gameTime);
        }
Exemple #2
0
        protected override void Update(GameTime gameTime)
        {
            if (button_timer < 20)
            {
                button_timer++;
            }

            if (Keyboard.GetState().IsKeyDown(Keys.Escape))
            {
                if (ecran == Screen.jeu)
                {
                    ecran = Screen.menu_pause;
                    menuMain = new Menu(Menu.MenuType.PauseMenu);
                    PlayMusic(MenuMusic);
                }
                else if (ecran == Screen.menu_principal)
                {
                    Exit();
                }
            }

            if (ecran == Screen.menu_principal)
            {
                int action = 0;

                if (button_timer == 20)
                {
                    action = menuMain.Update(Mouse.GetState(), Keyboard.GetState());
                }
                if (action == 1)
                {
                    ecran = Screen.selecteur_map;
                    menuMain = new Menu(Menu.MenuType.MapSelector);
                    button_timer = 0;
                }
                if (action == 2)
                {
                    ecran = Screen.menu_parametres;
                    menuMain = new Menu(Menu.MenuType.MenuGeneralSettings);
                    button_timer = 0;
                }
                if (action == 3)
                {
                    Exit();
                }
            }

            else if (ecran == Screen.selecteur_map)
            {
                int action = 0;
                compteur_delai++;

                if (compteur_delai > 20)
                {
                    compteur_delai = 20;
                }
                if (button_timer == 20)
                {
                    action = menuMain.Update(Mouse.GetState(), Keyboard.GetState());
                }
                if (action == 1 && compteur_delai >= 20)
                {
                    compteur_delai = 0;
                    compteur_thumbnails -= 1;
                    if (compteur_thumbnails < 0)
                    {
                        compteur_thumbnails = 0;
                    }
                }
                if (action == 2 && compteur_delai >= 20)
                {
                    compteur_delai = 0;
                    compteur_thumbnails += 1;
                    if (compteur_thumbnails > 3)
                    {
                        compteur_thumbnails = 3;
                    }
                }
                if (action == 3)
                {
                    if (compteur_thumbnails == 0)
                    {
                        Main = new GameMain();
                        Main.MainMap = new Map(LecteurMap.lecture("map01.txt"));
                        path_map = "map01.txt";
                    }
                    else if (compteur_thumbnails == 1)
                    {
                        Main = new GameMain();
                        Main.MainMap = new Map(LecteurMap.lecture("map02.txt"));
                        path_map = "map02.txt";
                    }
                    else if (compteur_thumbnails == 2)
                    {
                        Main = new GameMain();
                        Main.MainMap = new Map(LecteurMap.lecture("map03.txt"));
                        path_map = "map03.txt";
                    }
                    else if (compteur_thumbnails == 3)
                    {
                        Main = new GameMain();
                        Main.MainMap = new Map(LecteurMap.lecture("map04.txt"));
                        path_map = "map04.txt";
                    }
                    ecran = Screen.jeu;
                    PlayMusic(GamePlayMusic);
                    button_timer = 0;
                }
                if (action == 4)
                {
                    ecran = Screen.menu_principal;
                    menuMain = new Menu(Menu.MenuType.MainMenu);
                    button_timer = 0;
                }
            }

            else if (ecran == Screen.menu_pause)
            {
                int action = 0;

                if (button_timer == 20)
                {
                    action = menuMain.Update(Mouse.GetState(), Keyboard.GetState());
                }
                if (action == 1)
                {
                    ecran = Screen.jeu;
                    button_timer = 0;
                    PlayMusic(GamePlayMusic);
                }
                if (action == 2)
                {
                    ecran = Screen.menu_preferences;
                    menuMain = new Menu(Menu.MenuType.MenuPreferences);
                    button_timer = 0;
                }
                if (action == 3)
                {
                    ecran = Screen.menu_principal;
                    menuMain = new Menu(Menu.MenuType.MainMenu);
                    button_timer = 0;
                    StopMusic(MenuMusic);
                }
            }

            else if (ecran == Screen.menu_preferences)
            {
                int action = 0;

                if (button_timer == 20)
                {
                    action = menuMain.Update(Mouse.GetState(), Keyboard.GetState());
                }
                if (action == 1)
                {
                    MenuButton.language = "French";
                    menuMain = new Menu(Menu.MenuType.MenuPreferences);
                    button_timer = 0;
                }
                if (action == 2)
                {
                    MenuButton.language = "English";
                    menuMain = new Menu(Menu.MenuType.MenuPreferences);
                    button_timer = 0;
                }
                if (action == 3)
                {
                    MediaPlayer.Volume -= 0.1f;
                    button_timer = 0;
                }
                if (action == 4)
                {
                    MediaPlayer.Volume += 0.1f;
                    button_timer = 0;
                }
                if (action == 5)
                {
                    MediaPlayer.Volume = 0;
                    button_timer = 0;
                }
                if (action == 6)
                {
                    ecran = Screen.menu_pause;
                    menuMain = new Menu(Menu.MenuType.PauseMenu);
                    button_timer = 0;
                }
            }

            else if (ecran == Screen.menu_parametres)
            {
                int action = 0;

                if (button_timer == 20)
                {
                    action = menuMain.Update(Mouse.GetState(), Keyboard.GetState());
                }
                if (action == 1)
                {
                    MenuButton.language = "French";
                    menuMain = new Menu(Menu.MenuType.MenuGeneralSettings);
                    button_timer = 0;
                }
                if (action == 2)
                {
                    MenuButton.language = "English";
                    menuMain = new Menu(Menu.MenuType.MenuGeneralSettings);
                    button_timer = 0;
                }
                if (action == 3)
                {
                    MediaPlayer.Volume -= 0.1f;
                    button_timer = 0;
                }
                if (action == 4)
                {
                    MediaPlayer.Volume += 0.1f;
                    button_timer = 0;
                }
                if (action == 5)
                {
                    MediaPlayer.Volume = 0;
                    button_timer = 0;
                }
                if (action == 6)
                {
                    ecran = Screen.menu_principal;
                    menuMain = new Menu(Menu.MenuType.MainMenu);
                    button_timer = 0;
                }
                if (action == 7 && graphics.IsFullScreen == false)
                {
                    graphics.ToggleFullScreen();
                    button_timer = 0;
                }
                if (action == 8 && graphics.IsFullScreen == true)
                {
                    graphics.ToggleFullScreen();
                    button_timer = 0;
                }
                if (action == 9)
                {
                    ecran = Screen.credits;
                    menuMain = new Menu(Menu.MenuType.Credits);
                }
            }

            else if (ecran == Screen.credits)
            {
                int action = 0;

                if (button_timer == 20)
                {
                    action = menuMain.Update(Mouse.GetState(), Keyboard.GetState());
                }
                if (action == 1)
                {
                    ecran = Screen.menu_parametres;
                    menuMain = new Menu(Menu.MenuType.MenuGeneralSettings);
                    button_timer = 0;
                }
            }

            else if (ecran == Screen.jeu)
            {
                Main.Update(Mouse.GetState(), Keyboard.GetState(), gameTime, graphics.GraphicsDevice);

                if (Main.MainMap.game_over)
                {
                    ecran = Screen.game_over;
                    menuMain = new Menu(Menu.MenuType.GameOver);
                    StopMusic(GamePlayMusic);
                    loseEffect.Play();
                }
                if (Main.MainMap.fin_niveau.est_arrivee)
                {
                    ecran = Screen.win;
                    menuMain = new Menu(Menu.MenuType.WinScreen);
                    StopMusic(GamePlayMusic);
                    winEffect.Play();
                }
                if (Main.MainMap.boss_entry.combat_boss)
                {

                }
            }

            else if (ecran == Screen.game_over)
            {
                int action = 0;

                if (button_timer == 20)
                {
                    action = menuMain.Update(Mouse.GetState(), Keyboard.GetState());
                }
                if (action == 1)
                {
                    ecran = Screen.selecteur_map;
                    menuMain = new Menu(Menu.MenuType.MapSelector);
                    button_timer = 0;
                }
            }

            else if (ecran == Screen.win)
            {
                int action = 0;

                if (button_timer == 20)
                {
                    action = menuMain.Update(Mouse.GetState(), Keyboard.GetState());
                }
                if (action == 1)
                {
                    ecran = Screen.selecteur_map;
                    menuMain = new Menu(Menu.MenuType.MapSelector);
                    button_timer = 0;
                }
            }

            base.Update(gameTime);
        }