public override void Update(GameTime gameTime) { if (firstTime) { FondSonore.PlayDefeat(); firstTime = false; } mouseRec = new Rectangle(mouse.X, mouse.Y, 5, 5); if (mouse.LeftButton == ButtonState.Pressed && oldMouse.LeftButton == ButtonState.Released) { if (mouseRec.Intersects(boutonQuitter)) { // Deconnecte du reseau if (Serveur.clients.Count > 0) // Si on etait le serveur { Serveur.Shutdown(); } if (Client.client != null) // Si on etait un client { Client.client.Close(); } SceneHandler.ResetGameplay(); CrystalGate.FondSonore.Stop(); SceneHandler.gameState = GameState.MainMenu; } } }
public override void Update(GameTime gameTime) { if (firstTime) { FondSonore.PlayVictory(); firstTime = false; } mouseRec = new Rectangle(mouse.X, mouse.Y, 5, 5); if (mouse.LeftButton == ButtonState.Pressed && oldMouse.LeftButton == ButtonState.Released) { if (mouseRec.Intersects(boutonQuitter)) { SceneHandler.ResetGameplay(); CrystalGate.FondSonore.Stop(); SceneHandler.gameState = GameState.MainMenu; } } }
public override void Update(GameTime gameTime) { mouseRec = new Rectangle(mouse.X, mouse.Y, 5, 5); if (keyboardState.IsKeyDown(Keys.Escape) && !oldKeyboardState.IsKeyDown(Keys.Escape)) { FondSonore.Resume(); GamePlay.timer.Start(); SceneHandler.gameState = GameState.Gameplay; } if (mouse.LeftButton == ButtonState.Pressed && oldMouse.LeftButton == ButtonState.Released) { if (mouseRec.Intersects(boutonRetour)) { SceneHandler.gameState = GameState.Gameplay; GamePlay.timer.Start(); CrystalGate.FondSonore.Resume(); } else if (mouseRec.Intersects(boutonOption)) { SceneHandler.gameState = GameState.Setting; MenuOptions.isPauseOption = true; } else if (mouseRec.Intersects(boutonMenuPrincipal)) { SceneHandler.ResetGameplay(); CrystalGate.FondSonore.Stop(); SceneHandler.gameState = GameState.MainMenu; // Deconnecte du reseau if (Serveur.clients.Count > 0) // Si on etait le serveur { Serveur.Shutdown(); } if (Client.client != null) // Si on etait un client { Client.client.Close(); } } } }
public override void Update(GameTime gameTime) { mouseRec = new Rectangle(mouse.X, mouse.Y, 5, 5); UpdatePositions(); nbFrames++; for (int i = 0; i < portraits.Count; i++) { if (personnageSelectionne == i) { couleurAffichagePortrait[i] = Color.Cyan; } else if (mouseRec.Intersects(portraits[i])) { couleurAffichagePortrait[i] = Color.Gray; if (mouse.LeftButton == ButtonState.Pressed && oldMouse.LeftButton == ButtonState.Released) { personnageSelectionne = i; } } else { couleurAffichagePortrait[i] = Color.White; } } if (CoopConnexionScene.isOnlinePlay) { if (Client.isConnected) { Client.ownPlayer.championChoisi = personnageSelectionne; if (nbFrames % 15 == 0) { // On s'envoit MemoryStream stream = new MemoryStream(); BinaryFormatter formatter = new BinaryFormatter(); formatter.Serialize(stream, Client.ownPlayer); byte[] buffer = new byte[stream.Length]; stream.Position = 0; stream.Read(buffer, 0, buffer.Length); // Envoi Client.Send(buffer, 1); } } if (Serveur.IsRunning) // Si on est le serveur { bool everybodyHaveChose = true; for (int i = 0; i < Client.joueursConnectes.Count; i++) { everybodyHaveChose &= (Client.joueursConnectes[i].championChoisi != 1); } if (everybodyHaveChose) { lancerLeJeuActive = true; } } else // Le client ne peut pas lancer le jeu { lancerLeJeuActive = false; } } else // Si on joue en local il faut avoir sélectionné un perso avant de lancer le jeu if (personnageSelectionne == -1) { lancerLeJeuActive = false; } else { lancerLeJeuActive = true; } if (mouse.LeftButton == ButtonState.Pressed && oldMouse.LeftButton == ButtonState.Released) { if (mouseRec.Intersects(boutonLancerLeJeu) && personnageSelectionne != -1) { // C'est parti! if (Serveur.IsRunning) { Serveur.Send(BitConverter.GetBytes(3)); } else if (!Client.isConnected) { SceneHandler.ResetGameplay(); SceneHandler.gameState = GameState.Gameplay; FondSonore.Play(); GamePlay.timer.Restart(); } } else if (mouseRec.Intersects(boutonRetour)) { if (CoopConnexionScene.isOnlinePlay) { SceneHandler.gameState = GameState.CoopConnexion; } else { SceneHandler.gameState = GameState.MainMenu; } } } }