Ejemplo n.º 1
0
        internal void DrawAllGameObjects(GameDatabase db, SpriteBatch spriteBatch, StarField starfield)
        {
            starfield.Draw(spriteBatch);

            db.Enemies.GetAll().ForEach(e => e.Draw(spriteBatch));
            db.Bullets.GetAll().ForEach(b => b.Draw(spriteBatch));
            db.Asteroids.GetAll().ForEach(a => a.Draw(spriteBatch));
            db.Explosions.GetAll().ForEach(e => e.Draw(spriteBatch));

            foreach (var item in db.Items.GetAll())
            {
                item.Draw(spriteBatch);
            }
            db.Players.GetAll().ForEach(p => p.Draw(spriteBatch));
        }
Ejemplo n.º 2
0
        protected override void Draw(GameTime gameTime)
        {
            GraphicsDevice.Clear(Color.Black);

            spriteBatch.Begin();

            if (gameState == GameStates.TitleScreen)
            {
                spriteBatch.Draw(titleScreen,
                                 new Rectangle(0, 0, Window.ClientBounds.Width,
                                               Window.ClientBounds.Height), Color.White);
            }

            if ((gameState == GameStates.Playing) ||
                (gameState == GameStates.PlayerDead) ||
                (gameState == GameStates.GameOver))
            {
                starField.Draw(spriteBatch);
                asteroidManager.Draw(spriteBatch);
                playerManager.Draw(spriteBatch);
                enemyManager.Draw(spriteBatch);
                explosionManager.Draw(spriteBatch);

                spriteBatch.DrawString(pericles14, "Score: " +
                                       playerManager.PlayerScore.ToString(), scoreLocation, Color.Yellow);

                if (playerManager.LivesRemaining >= 0)
                {
                    spriteBatch.DrawString(pericles14, "Lives: " +
                                           playerManager.LivesRemaining.ToString(), livesLocation, Color.Yellow);
                }
            }

            if (gameState == GameStates.GameOver)
            {
                spriteBatch.DrawString(pericles14, "G A M E   O V E R",
                                       new Vector2(Window.ClientBounds.Width / 2 -
                                                   pericles14.MeasureString("G A M E   O V E R").X / 2, 50), Color.Red);
            }

            spriteBatch.End();

            base.Draw(gameTime);
        }
        public override void Draw(GameTime gameTime, SpriteBatch spriteBatch)
        {
            _starField.Draw(gameTime, spriteBatch);
            _asteroidManager.Draw(gameTime, spriteBatch);
            _player.Draw(gameTime, spriteBatch);
            _shotManager.Draw(gameTime, spriteBatch);
            _enemyManager.Draw(gameTime, spriteBatch);
            _pieceExplosionManager.Draw(gameTime, spriteBatch);
            _pointExplosionManager.Draw(gameTime, spriteBatch);


            spriteBatch.DrawString(_perecles14, "Score " + _playerScore, _scoreLocation, Color.White);
            if (_player.RemainingLives > 0)
            {
                spriteBatch.DrawString(_perecles14, "Ships Remaining: " + _player.RemainingLives, _livesLocation, Color.White);
            }

            if (_gameOver)
            {
                const string GameOverText = "G A M E   O V E R !";
                Vector2      loc          = new Vector2(ClientBounds.Width / 2 - _perecles14.MeasureString(GameOverText).X / 2, 50);
                spriteBatch.DrawString(_perecles14, GameOverText, loc, Color.White);
            }
        }