public void DrawText(ISpriteBatch spriteBatch, float elapsedSeconds) { foreach (var bubbleText in this.BubbleTexts) { float transitionOffset = 1 - (bubbleText.TimeRemaining / bubbleText.TotalTime); // Modulate size: float scale = MathHelper.SmoothStep(0f, 1f, transitionOffset) + 0.5f; // Modulate alpha: var color = new Color(bubbleText.Color.R, bubbleText.Color.G, bubbleText.Color.B, MathHelper.SmoothStep(1f, 0f, transitionOffset)); spriteBatch.DrawText(this.Font, bubbleText.Text, bubbleText.Position, color, scale); bubbleText.TimeRemaining -= elapsedSeconds; } this.BubbleTexts.RemoveAll((bubbleTxt) => bubbleTxt.TimeRemaining < 0); }
public void Draw(ISpriteBatch spritebatch) { Vector2 currentTextPosition = new Vector2(this.Window.Left + OverlaySetView.TEXT_OFFSET.X, this.Window.Top + OverlaySetView.TEXT_OFFSET.Y); spritebatch.DrawText(_font, ScoreOverlayView.PLAYER, currentTextPosition, HEADING_COLOR, 1); spritebatch.DrawText(_font, ScoreOverlayView.SCORE, currentTextPosition + SCORE_OFFSET, HEADING_COLOR, 1); spritebatch.DrawText(_font, ScoreOverlayView.DEATHS, currentTextPosition + DEATHS_OFFSET, HEADING_COLOR, 1); currentTextPosition.Y += _font.LineSpacing; foreach (IPlayer player in _playerList.Players.OrderByDescending((p) => p.PlayerScore)) { string name = player.PlayerSettings.Name; spritebatch.DrawText(_font, name.Substring(0, name.Length > MAX_NAME_LENGTH ? MAX_NAME_LENGTH : name.Length), currentTextPosition, VALUES_COLOR, 1); spritebatch.DrawText(_font, player.PlayerScore.Kills.ToString(), currentTextPosition + SCORE_OFFSET, VALUES_COLOR, 1); spritebatch.DrawText(_font, player.PlayerScore.Deaths.ToString(), currentTextPosition + DEATHS_OFFSET, VALUES_COLOR, 1); currentTextPosition.Y += _font.LineSpacing; } }