public override void Update(Game1 game, Audio audio) { KeyboardState keyboard = Keyboard.GetState(); MouseState mouse = Mouse.GetState(); if (keyboard.IsKeyUp(Microsoft.Xna.Framework.Input.Keys.Escape) && oldkey.IsKeyDown(Keys.Escape)) { _pause.checkpause(keyboard, ref _checkpause); } if (!_checkpause) { // ici le code de jeu update } else { game.ChangeState2(Game1.gameState.Checkpause); MediaPlayer.Stop(); ParticleAdder.adder(game, Game1.gameState.Checkpause, height, width); _pause.Update(game, audio, ref _checkpause); } oldkey = keyboard; }
public override void Update(Game1 game, Audio audio) { KeyboardState keyboard; keyboard = Keyboard.GetState(); if (keyboard.IsKeyDown(Keys.Escape) && latence <= 0) { _pause.checkpause(keyboard, ref _checkpause); latence = 30; } if (latence > 0) --latence; if (!_checkpause) { game.ChangeState2(Game1.gameState.Null); // scrolling verticale // scrolling1.Update(); // scrolling2.Update(); Scroll.Update(); //vaisseau vaisseau.Update(keyboard, game, oldkey); //update ia jbdcvf // aster.update(); ovini.Update(ref game_time) ; manage_T.Update(ref game, ref game_time); manage_V.Update(ref vaisseau, ref game_time); manage_k.Update(ref vaisseau, ref game_time); collision.hero_missile(manage_T, ref vaisseau); collision.hero_missile(manage_V, ref vaisseau); collision.col_H_IA(manage_k, ref vaisseau); collision.col_H_IA(manage_V, ref vaisseau); collision.col_H_IA(manage_T, ref vaisseau); // collision.Ovni_vaiss(ref ovini, ref vaisseau); //update collision collision.collision_ai_missile(ref vaisseau, manage_k); collision.collision_ai_missile(ref vaisseau, manage_V); collision.collision_ai_missile(ref vaisseau, manage_T); } else { game.ChangeState2(Game1.gameState.Checkpause); _pause.Update(game, audio, ref _checkpause); } // update fin de jeu if (manage_k.Ia_manage.Count == 0 && manage_T.Ia_manage.Count == 0 && manage_V.Ia_manage.Count == 0) { if (timer == -100) { vaisseau.gagne(); timer = vaisseau.rectangle.Y / 2; // aster.visible = false; manage_k.bulletL.Clear(); manage_T.bulletL.Clear(); manage_V.bulletL.Clear(); } if (timer < 0 && timer != -100) game.ChangeState(Game1.gameState.level_Pselect );//va au level2 timer--; } //update interface oldkey = keyboard; game_time++; }
public override void Update(Game1 game, Audio audio) { KeyboardState keyboard; MouseState mouse; mouse = Mouse.GetState(); keyboard = Keyboard.GetState(); if (keyboard.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.Escape) && latence <= 0) { _pause.checkpause(keyboard, ref _checkpause); latence = 30; user.Hide(); } if (latence > 0) --latence; if (!_checkpause) { if (mouse.LeftButton == Microsoft.Xna.Framework.Input.ButtonState.Pressed && !user.IHave_control) { spawn = existcheck(ref iaType, mouse); user._show(mouse.X, mouse.Y, iaType, spawn); } if (user.IHave_control) user.TopMost = true; else { user.update(ref manage_T, ref manage_V, ref manage_k, ref keyboard, game, ref Scroll_manager, ref ovni); // scrolling1.update_ophelia(keyboard); Scroll_manager.Update_ophelia(keyboard); } manage_k.Update_ophelia(keyboard); manage_T.Update_ophelia(keyboard); manage_V.Update_ophelia(keyboard); ovni.Update(keyboard); } else { game.ChangeState2(Game1.gameState.Checkpause); MediaPlayer.Stop(); ParticleAdder.adder(game, Game1.gameState.Checkpause, height, width); _pause.Update(game, audio, ref _checkpause); } //update interface oldkey = keyboard; }
public void Update(ref KeyboardState Key, ref KeyboardState old, ref MouseState mouse, ref Rectangle mouse_rec, ref Game1 game, ref int tab, string name1, ref bool pause) { if (tab == this.tab) { intecep = false; for (int i = 0; i < rect.GetLength(0); ++i) for (int j = 0; j < rect.GetLength(1); ++j) { if (mouse_rec.Intersects(rect[i, j])) { X = i; Y = j; intecep = true; } } if (old.IsKeyDown(Keys.Up) && Key.IsKeyUp(Keys.Up)) { Y = (Y - 1) % rect.GetLength(1); if (gameState[X, Y] == null) Y = (Y - 1) % rect.GetLength(1); } else if (old.IsKeyDown(Keys.Down) && Key.IsKeyUp(Keys.Down)) { Y = (Y + 1) % rect.GetLength(1); if (gameState[X, Y] == null) Y = (Y + 1) % rect.GetLength(1); } else if (old.IsKeyDown(Keys.Right) && Key.IsKeyUp(Keys.Right)) { X = (X + 1) % rect.GetLength(0); if (gameState[X, Y] == null) X = (X + 1) % rect.GetLength(0); } else if (old.IsKeyDown(Keys.Left) && Key.IsKeyUp(Keys.Left)) { X = (X - 1) % rect.GetLength(0); if (gameState[X, Y] == null) X = (X - 1) % rect.GetLength(0); } select = new Vector2(rect[X, Y].X - selection.Width, rect[X, Y].Y); if ((intecep && mouse.LeftButton == ButtonState.Pressed) || Key.IsKeyDown(Keys.Enter)) { if (gameState[X, Y] == "SEU") { game.level = levelname[X, Y]; game.ChangeState(Game1.gameState.SEU); } else if (gameState[X, Y] == "Checkpause") game.ChangeState(Game1.gameState.Checkpause); else if (gameState[X, Y] == "EditSEU") { game.level = "edit"; game.ChangeState(Game1.gameState.Editeur_mapVV); } else if (gameState[X, Y] == "Init") game.ChangeState(Game1.gameState.Initialisateur); else if (gameState[X, Y] == "LevelSelect") game.ChangeState(Game1.gameState.Level_select_state); else if (gameState[X, Y] == "Level2") { game.level = levelname[X, Y]; game.ChangeState(Game1.gameState.Level2); } else if (gameState[X, Y] == "Main") game.ChangeState(Game1.gameState.MainMenuState); else if (gameState[X, Y] == "Null") game.ChangeState(Game1.gameState.Null); else if (gameState[X, Y] == "Option") game.ChangeState(Game1.gameState.OptionsState); else if (gameState[X, Y] == "Pause") game.ChangeState(Game1.gameState.Pause); else if (gameState[X, Y] == "Play") game.ChangeState(Game1.gameState.PlayingState); else if (gameState[X, Y] == "LevelEdit") { if (name1 != string.Empty) game.level = name1; else game.level = name[X, Y]; if (game.level != "LevelEdit") game.ChangeState(Game1.gameState.leveleditor); } else if (gameState[X, Y] == "LevelSelect_P") game.ChangeState(Game1.gameState.level_Pselect); else if (gameState[X, Y] == "Exit") game.Exit(); else if (gameState[X, Y] == "Last") game.GetPreviousState(); else if (gameState[X, Y] == "Resume") game.ChangeState2(Game1.gameState.Null); else if (gameState[X, Y] == "Next") game.nextgame(); else if (gameState[X, Y] == "Replay") game.replay(); else game.ChangeState(Game1.gameState.MainMenuState); pause = false; System.Threading.Thread.Sleep(G_latence); } } }
public override void Update(Game1 game, Audio audio) { KeyboardState keyboard; keyboard = Keyboard.GetState(); if (keyboard.IsKeyDown(Keys.Escape) && latence <= 0) { _pause.checkpause(keyboard, ref _checkpause); latence = 30; } if (latence > 0) --latence; if (!_checkpause) { game.ChangeState2(Game1.gameState.Null); // scrolling scrolling1.Update(keyboard); // collision Allen if (collision.Collision_sp_sol(ref allen, ref platform_M)) { allen.marche(); allen.jump_off = true; allen.chute = false; } else { allen.air(); } allen.update(keyboard); //collision ia collision.collision_ia_sol(manageS, ref platform_M); manageS.Update(allen, ref keyboard); collision.collision_ia_AR_sol(managerAR, ref platform_M); managerAA.Update(ref keyboard); collision.collision_ia_sol(managerAA, ref platform_M); collision.coll_AL_IA(manageS, ref allen); collision.coll_AL_IA(managerAA , ref allen); collision.coll_AL_IA(managerAR, ref allen); //manager IA managerAR.Update(ref keyboard); //manager platform platform_M.Update(keyboard); } else { game.ChangeState2(Game1.gameState.Checkpause); MediaPlayer.Stop(); ParticleAdder.adder(game, Game1.gameState.Checkpause,height,width); _pause.Update(game, audio, ref _checkpause); } //partie perdu fail(game, allen, Game1.gameState.SEU); //audio if (allen.rectangle.Right >= width * 2 - 50) game.ChangeState(Game1.gameState.Pause, Game1.gameState.win ); }