/// <summary> /// Draws the menu. /// </summary> /// <param name="gameTime">Time passed since the last call to Draw.</param> public override void Draw(GameTime gameTime) { this.ScreenManager.SpriteBatch.Begin(); // Draw the background this.ScreenManager.SpriteBatch.Draw(this._background, this.ScreenManager.GraphicsDevice.Viewport.Bounds, Color.White); // Calculate the string position var text = (this._score - (int)(this._percentPointsToSubtract * this._score)).ToString(); var centerOfLocation = (int)(this._scoreLocation.X + ((this._scoreLocation.Right - this._scoreLocation.Left) / 2)); var leftOfCenter = (int)this._font.MeasureString(text).X / -2; var position = new Vector2(centerOfLocation + leftOfCenter, this._scoreLocation.Y); // Draw the score DrawingUtils.DrawShadowedString(this.ScreenManager.SpriteBatch, this._font, text, position, this._color); // Show the continue "menu" item if (this._transitionHelper.Position == 1.0f) { // Pulsate the size of the selected menu entry. double time = gameTime.TotalGameTime.TotalSeconds; float pulsate = (float)Math.Sin(time * 6) + 1; float scale = 1 + pulsate * 0.05f * this._selectionFade; this.ScreenManager.SpriteBatch.DrawString( this._menuFont, this._menuText, this._menuPosition, this._menuTextColor, 0, Vector2.Zero, scale, SpriteEffects.None, 0); } this.ScreenManager.SpriteBatch.End(); base.Draw(gameTime); }
/// <summary> /// Draws the menu. /// </summary> /// <param name="gameTime">Time passed since the last call to Draw.</param> public override void Draw(GameTime gameTime) { this.ScreenManager.SpriteBatch.Begin(); // Draw the background this.ScreenManager.SpriteBatch.Draw(this._background, this.ScreenManager.GraphicsDevice.Viewport.Bounds, Color.White); // Calculate the string position var text = (this._score + (int)(this._percentPointsToAdd * this._pointsToAward)).ToString(); var centerOfLocation = (int)(this._scoreLocation.X + ((this._scoreLocation.Right - this._scoreLocation.Left) / 2)); var leftOfCenter = (int)this._font.MeasureString(text).X / -2; var position = new Vector2(centerOfLocation + leftOfCenter, this._scoreLocation.Y); // Draw the score DrawingUtils.DrawShadowedString(this.ScreenManager.SpriteBatch, this._font, text, position, this._color); // Show the continue "menu" item if (this._showTextBox) { var centerX = this.ScreenManager.GraphicsDevice.Viewport.Width / 2; var centerY = this.ScreenManager.GraphicsDevice.Viewport.Height / 2; var centerXDialog = this._nameDialog.Width / 2; var centerYDialog = this._nameDialog.Height / 2; var dialogPosition = new Rectangle(centerX - centerXDialog, centerY - centerYDialog, this._nameDialog.Width, this._nameDialog.Height); this.ScreenManager.SpriteBatch.Draw(this._nameDialog, dialogPosition, Color.White); this._textBox.X = dialogPosition.X + 58; this._textBox.Y = dialogPosition.Y + 166; this._textBox.Width = 440; this._textBox.Draw(this.ScreenManager.SpriteBatch, gameTime); } else if (this._transitionHelper.State == TransitionHelper.TransitionState.Complete) { // Pulsate the size of the selected menu entry. double time = gameTime.TotalGameTime.TotalSeconds; float pulsate = (float)Math.Sin(time * 6) + 1; float scale = 1 + pulsate * 0.05f * this._selectionFade; this.ScreenManager.SpriteBatch.DrawString( this._menuFont, this._menuText, this._menuPosition, this._menuTextColor, 0, Vector2.Zero, scale, SpriteEffects.None, 0); } this.ScreenManager.SpriteBatch.End(); base.Draw(gameTime); }
/// <summary> /// Draws the HUD /// </summary> /// <param name="spriteBatch">The sprite batch.</param> public void Draw(SpriteBatch spriteBatch) { spriteBatch.Begin(); // Draw the Hud overlay. spriteBatch.Draw(this._hudTexture, this._hudRectangle, Color.White); // Draw time DrawingUtils.DrawShadowedString(spriteBatch, this._hudFont, _timeString, _timeLocation, _timeColor); // Draw score DrawingUtils.DrawShadowedString(spriteBatch, this._hudFont, string.IsNullOrEmpty(_scoreString) ? "$0.00" : String.Format("${0}", _scoreString), _scoreLocation, _defaultFontColor); // IF there's a message, show it if (!string.IsNullOrEmpty(_message)) { DrawingUtils.DrawShadowedString(spriteBatch, this._hudFont, _message, _messageLocation, _defaultFontColor); } spriteBatch.End(); }
/// <summary> /// Draws the specified sprite batch. /// </summary> /// <param name="spriteBatch">The sprite batch.</param> public void Draw(SpriteBatch spriteBatch) { spriteBatch.Begin(); DrawingUtils.DrawShadowedString(spriteBatch, this._hudFont, _timeString, _timeLocation, _timeColor); spriteBatch.End(); }