private void UpdateGameState() { switch (currentGameState) { case GameState.Start: // Wait until the player presses "Enter" to start the first level if (Keyboard.GetState().IsKeyDown(Keys.Enter)) { if (!videoPlaying) { audio.PlayCue("stateTransition"); audio.PlayBackgroundMusic("DigitalStream"); videoPlayer.Play(video); videoPlaying = true; } } UpdateVideo(); break; case GameState.Play: UpdateLevelState(); break; case GameState.End: break; default: throw new NotImplementedException("Invalid game state!"); } }
private void CreateLaserBeam() { Model laserBeamModel = Game.Content.Load <Model>(@"Models\Weapons\laserbeam"); laserBeam = new LaserBeam(laserBeamModel, camera); audio.PlayCue("laser"); }
private void CheckShipCollisions() { // Check for collisions with the ship for (int i = 0; i < ASTEROID_COUNT; i++) { if (asteroids[i].Collides(ship)) { audio.PlayCue("flashbang"); ship.col = new Vector3(1, 0, 0); status = "HIT!"; Explode = true; ship.damage_count++; times_hit++; } } }
//Shake Camera private void ShakeCamera(Camera camera) { int[] millsecondOffsets = { 50, 75, 100, 125, 150, 175 }; for (int i = 0; i < SHAKE_COUNT; i++) { int millisecondOffset = millsecondOffsets[i]; UpdateShake(millisecondOffset); } if ((milliseconds > (previousMilliseconds + 200) && test)) { audio.PlayCue("explosion"); camera.Direction = tempDirection; camera.Position = tempPosition; camera.Up = tempUp; camera.Yaw = tempYaw; camera.Pitch = tempPitch; camera.Roll = tempRoll; test = false; isShaking = false; shake[0] = false; } }