示例#1
0
        //#################################
        // Update
        //#################################
        public override void Update(GameTime gameTime, bool otherScreenHasFocus,
                                    bool coveredByOtherScreen)
        {
            base.Update(gameTime, otherScreenHasFocus, false);
            _soundEngine.Update();

            SoundDJ();
            PlayVoice();
            // Gradually fade in or out depending on whether we are covered by the pause screen.
            if (coveredByOtherScreen)
            {
                _pauseAlpha = Math.Min(_pauseAlpha + 1f / 32, 1);
            }
            else
            {
                _pauseAlpha = Math.Max(_pauseAlpha - 1f / 32, 0);
            }

            DebugFunctions();
            _input.Update();

            if (!coveredByOtherScreen)
            {
                if (_sphereAlpha > 0.1f)
                {
                    _sphereAlpha -= 0.001f;
                }

                //boids
                _waveBuilder.Update(gameTime, ref _asteroidField, ref _droneFleet);

                // calling update of objects where necessary
                _station.Update(gameTime);
                _planet.Update(gameTime);
                _droneFleet.Update(gameTime, !_station.IsDead);
                _asteroidField.Update(gameTime, _droneFleet.GetActiveDrone().Position);
                Global.Camera.updateCameraPositionTarget(_droneFleet.GetActiveDrone().Position + Global.CameraPosition, _droneFleet.GetActiveDrone().Position);


                // Particles
                dustParticles.Update(gameTime);
                UpdateBorder(gameTime);
                hitmarkerParticles.Update(gameTime);

                foreach (ExplosionSystem explosion in explosionList)
                {
                    explosion.Update(gameTime);
                    if (explosion._state == 2)
                    {
                        explosionRemoveList.Add(explosion);
                    }
                }

                foreach (var explosion in explosionRemoveList)
                {
                    explosionList.Remove(explosion);
                }
                explosionRemoveList.Clear();


                if (_waveBuilder.HasEnded && deadTime <= 0 && _station._health > 0)
                {
                    Global.HighScorePoints += Global.Money;
                    LoadingScreen.Load(ScreenManager, true, new BackgroundScreen(), new MainMenuScreen(), new HighscoreMenuScreenOnline(true));
                }
                // if station dies go back to MainMenu
                // TODO: change to EndScreen and HighScore list)
                if (_station._health <= 0 && deadTime <= 0)
                {
                    LoadingScreen.Load(ScreenManager, true, new BackgroundScreen(), new MainMenuScreen(), new HighscoreMenuScreenOnline(true));
                }

                CollisionHandling(gameTime);


                // fading out/in when drone is dead & alive again
                if (!_droneFleet.GetActiveDrone().IsNotDead)
                {
                    _deadDroneAlpha = Math.Min(_deadDroneAlpha + 1f / 32, 1);
                }
                else
                {
                    _deadDroneAlpha = Math.Max(_deadDroneAlpha - 1f / 32, 0);
                }

                // if fading out is max, respawn
                if (_actualDeadDroneAlpha >= 1f)
                {
                    _droneFleet.replaceOldDrone();
                    Global.HighScorePoints -= 200;
                    _deathCounter++;
                }
            }
        }
        //#################################
        // Update
        //#################################
        public override void Update(GameTime gameTime, bool otherScreenHasFocus,
                                    bool coveredByOtherScreen)
        {
            base.Update(gameTime, otherScreenHasFocus, false);

            if (once)
            {
                if (!voice)
                {
                    Global.Music.Stop();
                    voice = true;
                    Global.SpeakerVolume = 0;
                }
                if (Global.Music.Finished)
                {
                    once         = false;
                    Global.Music = Global.MusicEngine.Play2D("voice_intro", (Global.MusicVolume * 4 / 10), false);
                }
            }
            SoundDJ();
            if (_sphereAlpha > 0.1f)
            {
                _sphereAlpha -= 0.001f;
            }

            dustParticles.Update(gameTime);
            // Gradually fade in or out depending on whether we are covered by the pause screen.
            if (coveredByOtherScreen)
            {
                _pauseAlpha = Math.Min(_pauseAlpha + 1f / 32, 1);
            }
            else
            {
                _pauseAlpha = Math.Max(_pauseAlpha - 1f / 32, 0);
            }

            foreach (ExplosionSystem explosion in explosionList)
            {
                explosion.Update(gameTime);
            }

            // calling update of objects where necessary
            _station.Update(gameTime);
            _planet.Update(gameTime);
            if (movementAllowed)
            {
                _droneFleet.Update(gameTime, movementAllowed);
                _asteroidField.Update(gameTime, _station.Position);
            }

            Global.Camera.updateCameraPositionTarget(_droneFleet.GetActiveDrone().Position + Global.CameraPosition, _droneFleet.GetActiveDrone().Position);

            // if station dies go back to MainMenu
            // TODO: change to EndScreen and HighScore list)
            if (_station._health <= 0)
            {
                LoadingScreen.Load(ScreenManager, true, new BackgroundScreen(), new MainMenuScreen());
            }
            explosionParticles.Update(gameTime);
            CollisionHandling(gameTime);
            UpdateBorder(gameTime);

            // drone is dead
            if (!_droneFleet.GetActiveDrone().IsNotDead)
            {
                LoadingScreen.Load(ScreenManager, true, new BackgroundScreen(), new MainMenuScreen());
            }
        }