예제 #1
0
        public ScreenManager(Game game)
            : base(game)
        {
            _spriteBatch = (SpriteBatch)game.Services.GetService(typeof(SpriteBatch));

            // Sets initial screen to start screen since that is 
            // the first screen that is present in the game
            _activeScreen = new StartScreen(game, _spriteBatch);
        }
예제 #2
0
        public override void Update(ref Screen activeScreen, GameTime gameTime)
        {
            _scrollStartY -= (float)gameTime.ElapsedGameTime.TotalMilliseconds * 0.02f;

            if (_ambientSound == null)
            {
                _ambientSound = Resources.Instance.GetSound("theme").CreateInstance();
                _ambientSound.IsLooped = true;
                _ambientSound.Volume = 0.25f;
                _ambientSound.Play();
            }

            if (_loadScene)
            {
                _ambientSound.Stop();
                activeScreen = new GameScreen(_game, _spriteBatch);
            }
        }
예제 #3
0
        public override void Update(ref Screen activeScreen, GameTime gameTime)
        {
            if (Resources.Instance.shipHit && _hitTimer == 0)
            {
                Resources.Instance.Lives = Math.Max(Resources.Instance.Lives - 1, 0);
                Resources.Instance.GetSound("glass").Play();
            }
            if (Resources.Instance.shipHit && _hitTimer < _hitResetGoal)
            {
                _hitTimer += gameTime.ElapsedGameTime.Milliseconds;
            }
            else
            {
                _hitTimer = 0;
                Resources.Instance.shipHit = false;
            }

            if (_ambientSound == null)
            {
                _ambientSound = Resources.Instance.GetSound("game").CreateInstance();
                _ambientSound.IsLooped = true;
                _ambientSound.Volume = 0.5f;
                _ambientSound.Play();
            }

            if(!Resources.Instance.GameOver)
                _currentTime += (float)gameTime.ElapsedGameTime.TotalSeconds;
            if (_currentTime >= MAX_TIME)
            {
                Resources.Instance.PlayerWins = false;
                Resources.Instance.GameOver = true;
            }

            if (Keyboard.GetState().IsKeyDown(Keys.Escape))
            {
                Resources.Instance.Score = 0;

                foreach (KeyValuePair<int, MobileMeshModel> model in _manager.modelLookup)
                {
                    _game.Components.Remove(model.Value);
                }
                _manager.modelLookup.Clear();

                foreach (Emitter e in _manager.emitters)
                {
                    _game.Components.Remove(e.System);
                }
                _game.Components.Remove(_manager.skybox);
                _game.Components.Remove(_manager.GameBoundary);
                _game.Components.Remove(_manager.Ship);
                _game.Components.Remove(_manager);
                _ambientSound.Stop();
                activeScreen = new StartScreen(_game, _spriteBatch);
            }
        }
예제 #4
0
 // Passes reference so can change the screen based
 // off user input.
 public abstract void Update(ref Screen activeScreen, GameTime gameTime);