public gamemain(Game game, SpriteBatch spriteBatch, GameScreen activescreen) : base(game, spriteBatch) { #region init du jeu x = new Random(); liste_sort = new List<sort>(); list_zombi = new List<NPC>(); Walls = new List<wall>(); personnage = new List<Personnage>(); liste_objet_map = new List<potion>(); position_joueur = new Vector2(100, 100); localPlayer = new GamePlayer(34, 61, 4, 5, 2, 8, position_joueur, 100, ressource.sprite_player, this); localPlayer.Niveau = 1; pop_time = 0; score = 0; count_dead_zombi = 0; keyboard = new KeyboardState(); #endregion init du jeu map = new switch_map(localPlayer, this); fenetre = new Rectangle(0, 0, game.Window.ClientBounds.Width, game.Window.ClientBounds.Height); //taille de la fenetre HUD = new HUD(localPlayer, this); # region media_player; MediaPlayer.Play(ressource.main_theme); MediaPlayer.Volume = 0.56f; MediaPlayer.IsRepeating = true; // SoundEffect.MasterVolume = 0.6f; # endregion }
public item(Texture2D texture, GamePlayer player, Vector2 position, GameScreen screen) { Texture = texture; Position = position; }
protected override void LoadContent() { box = new textbox(new Rectangle(305, 200, 200, 50)); ressource.loadcontent(Content); spriteBatch = new SpriteBatch(GraphicsDevice); creation = new creat_perso(this, spriteBatch, ressource.pixel,language); Components.Add(creation); creation.hide(); gameover = new GameOverScreen(this, main, spriteBatch, ressource.ecriture, ressource.gameover, language); Components.Add(gameover); gameover.hide(); edm = new EDM(this, spriteBatch, language); Components.Add(edm); edm.hide(); pause = new menudepause(this, spriteBatch, ressource.ecriture, ressource.pixel, language); Components.Add(pause); pause.hide(); menu = new menu(this, spriteBatch, Content.Load<SpriteFont>("SpriteFont"), ressource.templar, language); Components.Add(menu); menu.hide(); //main = new gamemain(this, spriteBatch, activeScreen, new Donjon(@"Donjons\" + creation.donjon,false), false, ""); //Components.Add(main); //main.hide(); menudujeu = new menudujeu(this, spriteBatch, Content.Load<SpriteFont>("spriteFont"), ressource.th, language); Components.Add(menudujeu); menudujeu.hide(); Option = new option(this, spriteBatch, Content.Load<SpriteFont>("spriteFont"), ressource.option, language); Components.Add(Option); Option.hide(); inventaire = new Inventaire(this, spriteBatch, main, language); Components.Add(inventaire); inventaire.hide(); activeScreen = menu; activeScreen.Show(); MediaPlayer.Play(ressource.menu); MediaPlayer.IsRepeating = true; MediaPlayer.IsMuted = true; SoundEffect.MasterVolume = 0f; }
protected override void Update(GameTime gameTime) { keyboard = Keyboard.GetState(); mouse = Mouse.GetState(); Data.Update(); # region gameover if (activeScreen == gameover) { if (checkKey(Keys.Enter)) { if (gameover.SelectedIndex == 0) { main = new gamemain(this, spriteBatch, activeScreen, new Donjon(@"Donjons\" + creation.donjon, false), false, "", creation.donjon, language); Components.Add(main); main.hide(); ressource.selection.Play(); activeScreen.hide(); activeScreen = main; activeScreen.Show(); } if (gameover.SelectedIndex == 1) { ressource.selection.Play(); activeScreen.hide(); activeScreen = menu; activeScreen.Show(); if (main.Is_Server) main.Serveur.StopConnexion(); if (main.Is_Client) main.Client.StopConnexion(); } if (gameover.SelectedIndex == 2) { ressource.selection.Play(); if (main.Is_Server) main.Serveur.StopConnexion(); if (main.Is_Client) main.Client.StopConnexion(); this.Exit(); } } } #endregion #region menu_deuxJ if (activeScreen == menudeux) { if (Data.keyboardState.IsKeyDown(Keys.Escape)) { activeScreen.hide(); activeScreen = menu; activeScreen.Show(); } if (Data.keyboardState.IsKeyDown(Keys.Enter)) { /* main = new gamemain(this, spriteBatch, activeScreen, new Donjon(@"Donjons\" + creation.donjon, false), true, box.Saisie, creation.donjon, language); main.IP = menudeux.box.Saisie; main.Is_Client = menudeux.selec; main.Is_Server = !menudeux.selec;*/ Is_server = !menudeux.selec; Is_Client = menudeux.selec; if (Is_server) { ressource.selection.Play(); activeScreen.hide(); activeScreen = creation; activeScreen.Show(); } if (Is_Client) { client = new Client(box.Saisie); main = new gamemain(this, spriteBatch, activeScreen, null, true, box.Saisie, creation.donjon,language); Donjon donj = client.ReceiveDungeon(main); main.map = new switch_map(main.player, donj, donj.name); main.map.x = (int)donj.map.X; main.map.y = (int)donj.map.Y; main.Is_Client = true; main.Is_Server = false; main.Client = client; main.lZombie(); //main.AddLocalplayer(); main.AddHUD(); main.AddP2(); Components.Add(main); main.hide(); ressource.selection.Play(); activeScreen.hide(); activeScreen = main; activeScreen.Show(); } /* main.StartReseauConnexion(); Components.Add(main); main.hide(); ressource.selection.Play(); activeScreen.hide(); activeScreen = main; activeScreen.Show();*/ } } #endregion #region screen_menu_principal if (activeScreen == menu) { if (checkKey(Keys.Enter)) { if (menu.SelectedIndex == 0) { ressource.selection.Play(); menudujeu = new menudujeu(this, spriteBatch, Content.Load<SpriteFont>("spriteFont"), ressource.th, language); Components.Add(menudujeu); activeScreen.hide(); activeScreen = menudujeu; activeScreen.Show(); } else if (menu.SelectedIndex == 1) { ressource.selection.Play(); menudeux = new menudeux(this, spriteBatch, ref box); Components.Add(menudeux); creation.hide(); activeScreen.hide(); activeScreen = menudeux; activeScreen.Show(); } else if (menu.SelectedIndex == 2) { ressource.selection.Play(); edm = new EDM(this, spriteBatch, language); Components.Add(edm); activeScreen.hide(); activeScreen = edm; activeScreen.Show(); } else if (menu.SelectedIndex == 3) { ressource.selection.Play(); activeScreen.hide(); activeScreen = Option; activeScreen.Show(); } else if (menu.SelectedIndex == 4) { ressource.selection.Play(); this.Exit(); } } } #endregion #region creation else if (activeScreen == creation) { if (creation.change == true) { if (Is_server) { main = new gamemain(this, spriteBatch, activeScreen, new Donjon(@"Donjons\" + @creation.donjon, false), false, "", creation.donjon,language); main.Is_Server = true; main.Is_Client = false; main.StartReseauConnexion(); main.Serveur.SendDungeon(main.donj); Components.Add(main); main.hide(); creation.change = false; ressource.selection.Play(); activeScreen.hide(); activeScreen = main; activeScreen.Show(); } else { main = new gamemain(this, spriteBatch, activeScreen, new Donjon(@"Donjons\" + @creation.donjon, false), false, "", creation.donjon, language); Components.Add(main); main.hide(); creation.change = false; ressource.selection.Play(); activeScreen.hide(); activeScreen = main; activeScreen.Show(); } } } #endregion #region menu_1_Joueur else if (activeScreen == menudujeu) { if (checkKey(Keys.Enter)) { if (menudujeu.SelectedIndex == 0) { ressource.selection.Play(); creation = new creat_perso(this, spriteBatch, ressource.pixel,language); Components.Add(creation); activeScreen.hide(); activeScreen = creation; activeScreen.Show(); } else if (menudujeu.SelectedIndex == 1) { ressource.selection.Play(); activeScreen.hide(); activeScreen = main; activeScreen.Show(); } else if (menudujeu.SelectedIndex == 2) { ressource.selection.Play(); activeScreen.hide(); activeScreen = menu; activeScreen.Show(); } } } #endregion else if (activeScreen == victoire) { if(checkKey(Keys.Escape)) { activeScreen.hide(); activeScreen = menu; activeScreen.Show(); } } #region screen_action else if (activeScreen == main) { if (main.victoire == true) { victoire = new victory(this, spriteBatch); Components.Add(victoire); activeScreen.hide(); activeScreen = victoire; activeScreen.Show(); } if (main.player.pv_player <= 0) { gameover = new GameOverScreen(this, main, spriteBatch, ressource.ecriture, ressource.gameover, language); Components.Add(gameover); activeScreen.hide(); activeScreen = gameover; activeScreen.Show(); } if (checkKey(Keys.Escape)) { pause = new menudepause(this, spriteBatch, ressource.ecriture, ressource.pixel, language); Components.Add(pause); activeScreen.hide(); activeScreen = pause; activeScreen.Show(); } } #endregion #region inventaire else if (activeScreen == inventaire) { if (checkKey(Keys.Escape)) { activeScreen.hide(); activeScreen = main; activeScreen.Show(); } } #endregion #region screen_pause else if (activeScreen == pause) { if (checkKey(Keys.Enter)) { if (pause.SelectedIndex == 0) { activeScreen.hide(); inventaire = new Inventaire(this, spriteBatch, main, language); Components.Add(inventaire); activeScreen = inventaire; activeScreen.Show(); } else if (pause.SelectedIndex == 1) { activeScreen.hide(); carac = new Caracteristique(this, spriteBatch, main.player, language); Components.Add(carac); activeScreen = carac; activeScreen.Show(); } else if (pause.SelectedIndex == 2) { save = new Sauvegarde(main.map, main.player); save.Save(); activeScreen.hide(); activeScreen = main; activeScreen.Show(); } else if (pause.SelectedIndex == 3) { load = new Chargement(main.player, main.map, main.player, main); load.load_game(); activeScreen.hide(); activeScreen = main; activeScreen.Show(); } else if (pause.SelectedIndex == 4) { ressource.selection.Play(); if (main.Is_Server) main.Serveur.StopConnexion(); if (main.Is_Client) main.Client.StopConnexion(); activeScreen.hide(); activeScreen = menu; activeScreen.Show(); } } if (checkKey(Keys.Escape)) { activeScreen.hide(); activeScreen = main; activeScreen.Show(); } } #endregion #region screen_option else if (activeScreen == Option) { if (keyboard.IsKeyUp(Keys.H) && keyboard.IsKeyUp(Keys.J) && keyboard.IsKeyUp(Keys.K) && keyboard.IsKeyUp(Keys.L)) click_down = false; if (keyboard.IsKeyDown(Keys.L) && SoundEffect.MasterVolume < 0.99f && click_down == false) SoundEffect.MasterVolume += 0.01f; if (keyboard.IsKeyDown(Keys.K) && SoundEffect.MasterVolume > 0.01f && click_down == false) SoundEffect.MasterVolume -= 0.01f; if (keyboard.IsKeyDown(Keys.J) && MediaPlayer.Volume < 0.99f && click_down == false) MediaPlayer.Volume += 0.01f; if (keyboard.IsKeyDown(Keys.H) && MediaPlayer.Volume > 0.01f && click_down == false) MediaPlayer.Volume -= 0.01f; if (checkKey(Keys.Enter)) { if (Option.SelectedIndex == 0) { ressource.selection.Play(); if (ecran == false) { graphics.ToggleFullScreen(); ecran = true; } } if (Option.SelectedIndex == 1) { ressource.selection.Play(); if (ecran == true) { graphics.ToggleFullScreen(); ecran = false; } } if (Option.SelectedIndex == 2) { ressource.selection.Play(); MediaPlayer.IsMuted = false; SoundEffect.MasterVolume = 0.5f; } if (Option.SelectedIndex == 3) { ressource.selection.Play(); MediaPlayer.IsMuted = true; SoundEffect.MasterVolume = 0; } if (Option.SelectedIndex == 4) { ressource.selection.Play(); language = !language; Option = new option(this, spriteBatch, Content.Load<SpriteFont>("spriteFont"), ressource.option, language); Components.Add(Option); activeScreen.hide(); activeScreen = Option; activeScreen.Show(); } if (Option.SelectedIndex == 5) { ressource.selection.Play(); menu = new menu(this, spriteBatch, Content.Load<SpriteFont>("SpriteFont"), ressource.templar, language); Components.Add(menu); activeScreen.hide(); activeScreen = menu; activeScreen.Show(); } } } #endregion #region screen_EDM if (activeScreen == edm) { if (checkKey(Keys.Escape)) { activeScreen.hide(); activeScreen = menu; activeScreen.Show(); } } #endregion #region caracteristique if (activeScreen == carac) { if (checkKey(Keys.Escape)) { activeScreen.hide(); activeScreen = main; activeScreen.Show(); } } #endregion base.Update(gameTime); oldKeyboard = keyboard; oldmouse = mouse; }
protected override void LoadContent() { ressource.loadcontent(Content); spriteBatch = new SpriteBatch(GraphicsDevice); gameover = new GameOverScreen(this, spriteBatch, ressource.ecriture, ressource.gameover); Components.Add(gameover); gameover.hide(); edm = new EDM(this, spriteBatch); Components.Add(edm); edm.hide(); pause = new menudepause(this, spriteBatch, ressource.ecriture, ressource.pixel); Components.Add(pause); pause.hide(); menu = new menu(this, spriteBatch, Content.Load<SpriteFont>("SpriteFont"), ressource.templar); Components.Add(menu); menu.hide(); menudujeu = new menudujeu(this, spriteBatch, Content.Load<SpriteFont>("spriteFont"), ressource.th); Components.Add(menudujeu); menudujeu.hide(); option = new option(this, spriteBatch, Content.Load<SpriteFont>("spriteFont"), ressource.option); Components.Add(option); option.hide(); main = new gamemain(this, spriteBatch, activeScreen); Components.Add(main); main.hide(); activeScreen = menu; activeScreen.Show(); MediaPlayer.Play(ressource.menu); MediaPlayer.IsRepeating = true; SoundEffect.MasterVolume = 0.5f; ecran = false; }
protected override void Update(GameTime gameTime) { /* timer_musique++; while (MediaPlayer.Volume != 10) if (timer_musique == 30) { MediaPlayer.Volume++; timer_musique = 0; } */ keyboard = Keyboard.GetState(); # region gameover if (activeScreen == gameover) { if (checkKey(Keys.Enter)) { if (gameover.SelectedIndex == 0) { } if (gameover.SelectedIndex == 1) { ressource.selection.Play(); activeScreen.hide(); activeScreen = menu; activeScreen.Show(); } if (gameover.SelectedIndex == 2) { ressource.selection.Play(); this.Exit(); } } } #endregion #region screen_menu_principal if (activeScreen == menu) { if (checkKey(Keys.Enter)) { if (menu.SelectedIndex == 0) { ressource.selection.Play(); activeScreen.hide(); activeScreen = menudujeu; activeScreen.Show(); } else if (menu.SelectedIndex == 1) { } else if (menu.SelectedIndex == 2) { ressource.selection.Play(); activeScreen.hide(); activeScreen = edm; activeScreen.Show(); } else if (menu.SelectedIndex == 3) { ressource.selection.Play(); activeScreen.hide(); activeScreen = option; activeScreen.Show(); } else if (menu.SelectedIndex == 4) { ressource.selection.Play(); this.Exit(); } } } #endregion #region menu_1_Joueur else if (activeScreen == menudujeu) { if (checkKey(Keys.Enter)) { if (menudujeu.SelectedIndex == 0) { main = new gamemain(this, spriteBatch, activeScreen); Components.Add(main); main.hide(); ressource.selection.Play(); activeScreen.hide(); activeScreen = main; activeScreen.Show(); } else if (menudujeu.SelectedIndex == 1) { ressource.selection.Play(); activeScreen.hide(); activeScreen = main; activeScreen.Show(); } else if (menudujeu.SelectedIndex == 2) { ressource.selection.Play(); activeScreen.hide(); activeScreen = menu; activeScreen.Show(); } } } #endregion #region screen_action else if (activeScreen == main) { if (checkKey(Keys.Escape)) { activeScreen.hide(); activeScreen = pause; activeScreen.Show(); } } #endregion #region screen_pause else if (activeScreen == pause) { if (checkKey(Keys.Enter)) { if (pause.SelectedIndex == 0) { } else if (pause.SelectedIndex == 1) { } else if (pause.SelectedIndex == 2) { } else if (pause.SelectedIndex == 3) { ressource.selection.Play(); activeScreen.hide(); activeScreen = menu; activeScreen.Show(); } } if (checkKey(Keys.Escape)) { activeScreen.hide(); activeScreen = main; activeScreen.Show(); } } #endregion #region screen_option else if (activeScreen == option) { if (keyboard.IsKeyUp(Keys.H)) click_down = false; if (keyboard.IsKeyUp(Keys.J)) click_down = false; if (keyboard.IsKeyDown(Keys.K)) { SoundEffect.MasterVolume += 0.1f; } if (keyboard.IsKeyDown(Keys.L)) { SoundEffect.MasterVolume -= 0.1f; } if (keyboard.IsKeyDown(Keys.H) && click_down == false) { click_down = true; MediaPlayer.Volume += 0.1f; } if (keyboard.IsKeyDown(Keys.J) && click_down == false) { MediaPlayer.Volume -= 0.1f; click_down = true; } if (checkKey(Keys.Enter)) { if (option.SelectedIndex == 0) { ressource.selection.Play(); if (ecran == false) { graphics.ToggleFullScreen(); graphics.PreferredBackBufferHeight = 1920; graphics.PreferredBackBufferWidth = 1080; ecran = true; } } if (option.SelectedIndex == 1) { ressource.selection.Play(); if (ecran == true) { graphics.ToggleFullScreen(); graphics.PreferredBackBufferHeight = 1920; graphics.PreferredBackBufferWidth = 1080; ecran = false; } } if (option.SelectedIndex == 2) { ressource.selection.Play(); MediaPlayer.IsMuted = false; SoundEffect.MasterVolume = 0.5f; } if (option.SelectedIndex == 3) { ressource.selection.Play(); MediaPlayer.IsMuted = true; SoundEffect.MasterVolume = 0; } if (option.SelectedIndex == 4) { ressource.selection.Play(); activeScreen.hide(); activeScreen = menu; activeScreen.Show(); } } } #endregion #region screen_EDM if (activeScreen == edm) { if (checkKey(Keys.Escape)) { activeScreen.hide(); activeScreen = pause; activeScreen.Show(); } } #endregion base.Update(gameTime); oldKeyboard = keyboard; }
public gamemain(Game game, SpriteBatch spriteBatch, GameScreen activescreen, Donjon donjon, bool is2p, string ip, string name_donjon, bool language) : base(game, spriteBatch) { victoire = false; langue = language; nom_donjon = name_donjon; fenetre = new Rectangle(0, 0, game.Window.ClientBounds.Width, game.Window.ClientBounds.Height); //taille de la fenetre text = new textbox(new Rectangle(0, 18 * 32 + 7, 200, 100)); text.Is_shown = false; #region init du jeu x = new Random(); keyboard = new KeyboardState(); liste_sort = new List<sort>(); //ICI POUR LOADMOB //FIN ICI Walls = new List<wall>(); personnage = new List<Personnage>(); liste_objet_map = new List<potion>(); if (is2p) { position_joueur = new Vector2(32, 32); localPlayer = new GamePlayer(32, 48, 4, 8, 2, 15, 2, position_joueur, ressource.sprite_player, this, text, language); localPlayer.Niveau = 1; } if (!is2p) { position_joueur = donjon.position_J; localPlayer = new GamePlayer(32, 48, 4, 8, 2, 15, 2, position_joueur, ressource.sprite_player, this, text, language); localPlayer.Niveau = 1; for (int i = 0; i < 5; i++) { for (int j = 0; j < 5; j++) { if (donjon.Map[i, j] != null) donjon.Map[i, j].load_mob(@"Donjons\" + @name_donjon + @"\Map" + donjon.Map[i, j].Nb + @"\creature" + @".txt", this); } } } donj = donjon; if (!is2p) { map = new switch_map(localPlayer/*, this*/, donjon, name_donjon); map.x = (int)donjon.map.X; map.y = (int)donjon.map.Y; mapx = map.x; mapy = map.y; list_zombi = map.Active_Map.monstre; HUD = new HUD(localPlayer, this); } pop_time = 0; score = 0; count_dead_zombi = 0; #endregion init du jeu # region media_player; MediaPlayer.Play(ressource.main_theme); MediaPlayer.Volume = 0.56f; MediaPlayer.IsRepeating = true; # endregion noir.A = 200; noir.B = noir.G = noir.R = 0; white = Color.White; white.A = 120; effect = new BasicEffect(game.GraphicsDevice); same_map = true; }