示例#1
0
 public Level(Game game, ParticleLibrary _particleEffects, ref SoundPlayer _soundPlayer, Scene _scene, Player _playerOne, int peeps, int _levelNumber)
 {
     levelNumber = _levelNumber;
     particleEffects = _particleEffects;
     peepsLeft = peeps;
     scene = _scene;
     scene.Camera.ResetCamera();
     soundPlayer = _soundPlayer;
     map = new Map(game, new Vector3(8, 7, 4), scene.Light, peepsLeft);
     playerOne = _playerOne;
     playerOne.SetStartPosition(map.GetPlayerStartPosition());
     playerOne.SetPlayArea(map.GetPlayArea());
     playerOne.AttachParticleLibrary(particleEffects);
     playerOne.AttachSoundPlayer(ref _soundPlayer);
     playerOne.Reset();
     playerCollisionCheck = CollisionType.None;
     skybox = new Base3DObject(game, "Models/skybox", scene.Light);
     gameHud = new Hud(game.Content, game.GraphicsDevice.Viewport.TitleSafeArea);
 }
示例#2
0
        public void Initialize(Game _game)
        {
            game = _game;
            scene = new Scene(game);
            pauseScreen = new PauseScreen(game.Content, "Screens/pause", "Fonts/OCR");
            levelCompleteScreen = new LevelCompleteScreen(game.Content, "Screens/levelcomplete", "Fonts/OCR");
            InitParticles();
            startPeeps = gameOptions.StartPeeps;
            levelCount = 0;
            soundPlayer = new SoundPlayer(game.Content);
            soundPlayer.AddSound("Reward", "Audio\\Effects\\reward", false);
            soundPlayer.AddSound("Explosion", "Audio\\Effects\\explosion", false);
            soundPlayer.AddSound("Thrust", "Audio\\Effects\\thrust", true);
            soundPlayer.AddSound("Scream", "Audio\\Effects\\scream", false);
            soundPlayer.AddSound("ScoreUp", "Audio\\Effects\\scoreup", false);
            MediaPlayer.IsRepeating = true;
            MediaPlayer.Volume = gameOptions.MusicVolumeAtPlay;
            MediaPlayer.Play(game.Content.Load<Song>("Audio\\Music\\Pulse"));

            playerOne = new Player(game, "Models/ship", scene.Light);
            playerOne.Fuel=gameOptions.StartFuel;
            playerOne.StartFuel=gameOptions.StartFuel;
            playerOne.Score = 0;
            playerOne.Lives = gameOptions.StartLives;
            CreateLevel();
        }
示例#3
0
        public void Update(GameTime gameTime, InputState input, PlayerIndex[] controllingPlayer, ref ApplicationState appState, ref Player playerOne)
        {
            scene.Camera.Move(input, controllingPlayer);
            skybox.Update(gameTime);
            map.Update(gameTime);
            playerOne.Move(input, controllingPlayer);
            playerOne.Update(gameTime);

            playerCollisionCheck = map.CheckBuildingCollision(playerOne);
            //has player hit the building, if so they deaded
            if (playerCollisionCheck == CollisionType.Building)
            {
                playerOne.Die();
                soundPlayer.StopAllSounds();
                soundPlayer.PlaySound("Explosion");
            }
            //has player landed too hard, if so they deaded, if there is a peep they deaded too
            if (playerCollisionCheck == CollisionType.Roof && playerOne.SafeDescent() == false)
            {
                if (map.CheckPeepCollision(playerOne))
                {
                    peepsLeft--;
                }
                playerOne.Die();
                soundPlayer.StopAllSounds();
                soundPlayer.PlaySound("Explosion");
            }
            //has the player landed safely, if there is a peep he is abducted
            if (playerCollisionCheck == CollisionType.Roof && playerOne.SafeDescent() == true)
            {
                if (map.CheckPeepCollision(playerOne))
                {
                    peepsLeft--;
                    playerOne.Score += gameOptions.PeepValue;
                    soundPlayer.PlaySound("Scream");
                }

                if (map.CheckPowerupCollision(playerOne))
                {
                    playerOne.Fuel += gameOptions.PowerupFuel;
                    soundPlayer.PlaySound("Reward");
                }
            }

            if (playerOne.Lives <= 0)
            {
                soundPlayer.StopAllSounds();
                appState = ApplicationState.GameOver;
            }
            if (peepsLeft <= 0 && playerOne.Lives>0)
            {
                soundPlayer.StopAllSounds();
                soundPlayer.PlaySound("ScoreUp");
                appState = ApplicationState.LevelComplete;
            }

            gameHud.Update(gameTime, playerOne.Lives, playerOne.Score, playerOne.Fuel, peepsLeft);

            if (Keyboard.GetState().IsKeyDown(Keys.P))
            {
                Console.WriteLine(scene.Camera.Position + " - " + scene.Camera.View + "." + " - " + playerOne.Position);
            }
        }