protected override void Initialize() { GameText.initGameText(); scene = new SceneEngine2.SceneHandler(); SceneEngine2.SceneHandler.content = Content; Unite.rand = new Random(); exit = false; base.Initialize(); }
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; } } } }
public override void Update(GameTime gameTime) { mouseRec = new Rectangle(mouse.X, mouse.Y, 5, 5); if (endFirstClic && mouse.LeftButton == ButtonState.Pressed) { if (mouseRec.Intersects(volumeEffects)) { EffetSonore.volume = (float)(mouse.X - volumeEffects.X) / volumeEffects.Width; } else if (mouseRec.Intersects(volumeFondSonore)) { FondSonore.volume = (float)(mouse.X - volumeFondSonore.X) / volumeEffects.Width; FondSonore.UpdateVolume(); } else if (oldMouse.LeftButton == ButtonState.Released) { if (mouseRec.Intersects(boutonPleinEcran)) { isFullscreen = !isFullscreen; CrystalGate.CrystalGateGame.graphics.ToggleFullScreen(); } else if (mouseRec.Intersects(boutonLangue)) { _currentLanguage++; if (_currentLanguage > Language.Français) { _currentLanguage = 0; } if (_currentLanguage == Language.Français) { GameText.langue = "french"; } else if (_currentLanguage == Language.English) { GameText.langue = "english"; } GameText.initGameText(); } else if (mouseRec.Intersects(boutonResolution)) { _currentRes++; if (_currentRes == possibleResolutions.Count) { _currentRes = 0; } CrystalGateGame.graphics.PreferredBackBufferWidth = possibleResolutions[_currentRes].width; CrystalGateGame.graphics.PreferredBackBufferHeight = possibleResolutions[_currentRes].height; CrystalGateGame.graphics.ApplyChanges(); SceneHandler.UpdatePositions(); } else if (mouseRec.Intersects(boutonCredits)) { SceneHandler.gameState = GameState.Credits; SceneHandler.creditsScene.ecranPrecedent = GameState.Setting; SceneHandler.creditsScene.Reinit(); } else if (mouseRec.Intersects(boutonRetour)) { if (isPauseOption) { SceneHandler.gameState = GameState.Pause; } else { SceneHandler.gameState = GameState.MainMenu; } endFirstClic = false; } } } else if (!endFirstClic && mouse.LeftButton == ButtonState.Released) { endFirstClic = true; } if (isPauseOption && keyboardState.IsKeyDown(Keys.Escape)) { SceneHandler.gameState = GameState.Gameplay; } fullscreenText = (isFullscreen ? noT.get() : yesT.get()); positionTexteVolumeEffects = new Vector2(volumeEffects.Left - spriteFont.MeasureString(effetSonoreT.get() + " :").X, volumeEffects.Center.Y - spriteFont.MeasureString(effetSonoreT.get() + " :").Y / 2); positionTexteVolumeFondSonore = new Vector2(volumeFondSonore.Left - spriteFont.MeasureString(fondSonoreT.get() + " :").X, volumeFondSonore.Center.Y - spriteFont.MeasureString(fondSonoreT.get() + " :").Y / 2); positionTexteFullscreen = new Vector2(boutonPleinEcran.Left - spriteFont.MeasureString(pleinEcranT.get() + " :").X, boutonPleinEcran.Center.Y - spriteFont.MeasureString(pleinEcranT.get() + " :").Y / 2); positionTexteLangue = new Vector2(boutonLangue.Left - spriteFont.MeasureString(langueT.get() + " :").X, boutonLangue.Center.Y - spriteFont.MeasureString(langueT.get() + " :").Y / 2); positionTexteResolution = new Vector2(boutonResolution.Left - spriteFont.MeasureString(resolutionT.get() + " :").X, boutonResolution.Center.Y - spriteFont.MeasureString(resolutionT.get() + " :").Y / 2); }