/// <summary>
        /// This is called when the game should draw itself.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Draw(GameTime gameTime)
        {
            // Clear screen to black
            GraphicsDevice.Clear(Color.Black);

            //Draw the skybox
            skyBox.Draw(gameTime, chaseCamera);

            // Turn on depth buffering for the models, effects and local backgrounds
            GraphicsDevice.RenderState.DepthBufferEnable      = true;
            GraphicsDevice.RenderState.DepthBufferWriteEnable = true;

            // Draw the local planet(s) and sun(s)
            earth.Draw(gameTime, chaseCamera);
            air.Draw(gameTime, chaseCamera);

            sun.Draw(gameTime, chaseCamera);

            //Draw the motion effect particles
            motionField.Draw(gameTime, chaseCamera);

            // Draw the ships
            playerShip.Draw(gameTime, chaseCamera);
            enemyShip.Draw(gameTime, chaseCamera);

            // Draw the weapons
            boltManager.Draw(gameTime, chaseCamera);

            // Draw the Heads Up Display Items here
            if (enemyShip.IsDestroyed)
            {
                spriteBatch.Begin();
                Vector2 stringLength = enemyShip.HudFont.MeasureString("You Win!");
                spriteBatch.DrawString(enemyShip.HudFont, "You Win!", new Vector2((GraphicsDevice.Viewport.Width - stringLength.X) / 2.0f, (GraphicsDevice.Viewport.Height - stringLength.Y) / 2.0f), Color.Yellow);
                spriteBatch.End();
            }
            else if (playerShip.IsDestroyed)
            {
                spriteBatch.Begin();
                Vector2 stringLength = enemyShip.HudFont.MeasureString("You Lose!");
                spriteBatch.DrawString(enemyShip.HudFont, "You Lose!", new Vector2((GraphicsDevice.Viewport.Width - stringLength.X) / 2.0f, (GraphicsDevice.Viewport.Height - stringLength.Y) / 2.0f), Color.Red);
                spriteBatch.End();
            }
            else
            {
                // draw the target box around the current (only!) target
                // along with range information.
                enemyShip.DrawHeadsUpDisplay(chaseCamera, playerShip);
            }

            // This draws the particle effects plus any other game components set to draw
            base.Draw(gameTime);
        }
示例#2
0
        protected override void Draw(GameTime gameTime)
        {
            GraphicsDevice.Clear(Color.CornflowerBlue);

            // TODO: Add your drawing code here
            _spriteBatch.Begin();
            player.Draw(_spriteBatch);
            foreach (Enemy e in enemies)
            {
                e.Draw(_spriteBatch);
            }
            foreach (GoldCoin gc in goldCoins)
            {
                gc.Draw(_spriteBatch);
            }

            printText.Print("Points:" + player.Points, _spriteBatch, 0, 0);
            _spriteBatch.End();

            base.Draw(gameTime);
        }