/// <summary> /// Draws the background screen. /// </summary> public override void Draw(GameTime gameTime) { if (starfield != null) { // update the parallax movement movement += gameTime.ElapsedGameTime.TotalSeconds; Vector2 position = Vector2.Multiply(new Vector2( (float)Math.Cos(movement / starsParallaxPeriod), (float)Math.Sin(movement / starsParallaxPeriod)), starsParallaxAmplitude); // draw the stars starfield.Draw(position); } // draw the title texture if (titleTexture != null) { Vector2 titlePosition = new Vector2( ScreenManager.TitleSafeArea.X + (ScreenManager.TitleSafeArea.Width - titleTexture.Width) / 2f, ScreenManager.TitleSafeArea.Y + ScreenManager.TitleSafeArea.Height * 0.05f); titlePosition.Y -= (float)Math.Pow(TransitionPosition, 2) * titlePosition.Y; ScreenManager.SpriteBatch.Begin(); ScreenManager.SpriteBatch.Draw(titleTexture, titlePosition, new Color(255, 255, 255, TransitionAlpha)); ScreenManager.SpriteBatch.End(); } }
/// <summary> /// Draws the gameplay screen. /// </summary> public override void Draw(GameTime gameTime) { float elapsedTime = (float)gameTime.ElapsedGameTime.TotalSeconds; if (networkSession != null) { // make sure we know what the local ship is if ((localShip == null) && (networkSession.LocalGamers.Count > 0)) { PlayerData playerData = networkSession.LocalGamers[0].Tag as PlayerData; if (playerData.Ship != null) { localShip = playerData.Ship; starfield.Reset(localShip.Position); } } if (bloomComponent != null) { bloomComponent.BeginDraw(); } // draw the world if ((world != null) && (localShip != null) && !IsExiting) { Vector2 center = new Vector2( localShip.Position.X + ScreenManager.GraphicsDevice.Viewport.X - ScreenManager.GraphicsDevice.Viewport.Width / 2, localShip.Position.Y + ScreenManager.GraphicsDevice.Viewport.Y - ScreenManager.GraphicsDevice.Viewport.Height / 2); starfield.Draw(center); world.Draw(elapsedTime, center); if (bloomComponent != null) { bloomComponent.Draw(gameTime); } } // draw the user-interface elements of the game (scores, etc.) DrawHud((float)gameTime.TotalGameTime.TotalSeconds); } // If the game is transitioning on or off, fade it out to black. if (ScreenState == ScreenState.TransitionOn && (TransitionPosition > 0)) { ScreenManager.FadeBackBufferToBlack(255 - TransitionAlpha); } }