public void Draw(SpriteBatch spriteBatch) { _tempPosition = _position; var maxRows = 5; var startIndex = Math.Max(0, 1 + _mode.CurrentRoundIndex - maxRows); var endIndex = Math.Min(_mode.MaxRounds, startIndex + maxRows); for (var i = startIndex; i < endIndex; i++) { var color = Color.White; if (i == _mode.CurrentRoundIndex) { color = Color.Yellow; } else if (i > _mode.CurrentRoundIndex) { color *= 0.33f; } var round = _mode.CurrentPlayer.Rounds[i]; var text = "R" + (i + 1) + ". "; var font = ScreenManager.Trebuchet24; var textSize = font.MeasureString(text); TextBlock.DrawShadowed(spriteBatch, font, text, color, _tempPosition + new Vector2(0, -textSize.Y * 0.225f)); _tempPosition.X += font.MeasureString(text).X; _drawRoundMarks(spriteBatch, round); _tempPosition.X = _position.X; _tempPosition.Y += _font.LineSpacing; } }
/// <summary> /// Draws the score that is displayed for each round to left of the screen /// </summary> /// <param name="spriteBatch"></param> public void Draw(SpriteBatch spriteBatch) { var font = ScreenManager.Trebuchet24; var tempPosition = _position; var maxRows = 5; var startIndex = Math.Max(0, 1 + _mode.CurrentRoundIndex - maxRows); var endIndex = Math.Min(_mode.MaxRounds, startIndex + maxRows); for (var i = startIndex; i < endIndex; i++) { var round = _mode.CurrentPlayer.Rounds[i]; var roundScore = round.GetScore(); var roundScoreColor = getRoundScoreColor(round); if (i == _mode.CurrentRoundIndex) { roundScoreColor = Color.Yellow; //Color.Lerp(Color.LightYellow, Color.Yellow, (float) ((Math.Sin(_mode._elapsedTime*1.0f/500f) + 1.0f)/2.0f)); } else if (i > _mode.CurrentRoundIndex) { roundScoreColor = Color.White * 0.33f; } var text = "R" + (i + 1) + ". " + roundScore; TextBlock.DrawShadowed(spriteBatch, font, text, roundScoreColor, tempPosition); tempPosition.Y += font.LineSpacing; } }
/// <summary> /// Draws the score that is displayed for each round to left of the screen /// </summary> /// <param name="spriteBatch"></param> public void Draw(SpriteBatch spriteBatch) { var position = new Vector2(20, XnaDartsGame.Viewport.Height * 0.33f); var font = ScreenManager.Trebuchet24; for (var i = 0; i < _mode.CurrentPlayer.Rounds.Count; i++) { var round = _mode.CurrentPlayer.Rounds[i]; var roundScore = _mode.GetScore(round); var roundScoreColor = getRoundScoreColor(round); if (i == _mode.CurrentRoundIndex) { roundScoreColor = Color.Yellow; //Color.Lerp(Color.LightYellow, Color.Yellow, (float) ((Math.Sin(_mode._elapsedTime*1.0f/500f) + 1.0f)/2.0f)); } else if (i > _mode.CurrentRoundIndex) { roundScoreColor = Color.White * 0.33f; } var text = "R" + (i + 1) + "." + roundScore; TextBlock.DrawShadowed(spriteBatch, font, text, roundScoreColor, position); position.Y += font.LineSpacing * 0.8f; } }
public override void Draw(SpriteBatch spriteBatch) { base.Draw(spriteBatch); spriteBatch.Begin(); const float spacing = 12.0f; var players = _gameplayScreen.Mode.Players; var width = XnaDartsGame.Viewport.Width / (float)players.Count * 0.8f; var position = new Vector2(XnaDartsGame.Viewport.Width * 0.5f - width * players.Count * 0.5f, XnaDartsGame.Viewport.Height * 0.2f); var font = ScreenManager.Trebuchet24; for (var i = 0; i < players.Count; i++) { TextBlock.DrawShadowed(spriteBatch, font, players[i].Name, _gameplayScreen.Mode.GetPlayerColor(players[i]) * TransitionAlpha, position); position.Y += font.MeasureString(players[i].Name).Y + spacing; for (var j = 0; j < players[i].Rounds.Count; j++) { var text = ""; if (i == 0) { text += "R" + (j + 1) + "."; } for (var k = 0; k < players[i].Rounds[j].Darts.Count; k++) { switch (players[i].Rounds[j].Darts[k].Multiplier) { case 2: text += "D"; break; case 3: text += "T"; break; } text += players[i].Rounds[j].Darts[k].Segment.ToString(); if (k != players[i].Rounds[j].Darts.Count - 1) { text += ","; } } TextBlock.DrawShadowed(spriteBatch, font, text, Color.White * TransitionAlpha, position); position.Y += font.LineSpacing + spacing; } position.X += width + spacing; position.Y = XnaDartsGame.Viewport.Height * 0.2f; } spriteBatch.End(); }
private void drawCurrentPlayerName(SpriteBatch spriteBatch) { var position = new Vector2(20, 200); var bigFont = ScreenManager.Trebuchet32; TextBlock.DrawShadowed(spriteBatch, bigFont, _mode.CurrentPlayer.Name, _mode.GetPlayerColor(_mode.CurrentPlayer), position); position.Y += bigFont.LineSpacing; }
private void _drawDartScoreInText(SpriteBatch spriteBatch, Dart dart, Vector2 dartPosition) { string text; Color color; dart.GetVerbose(out text, out color); var textOffset = ScreenManager.Trebuchet32.MeasureString(text) * 0.5f; TextBlock.DrawShadowed(spriteBatch, ScreenManager.Trebuchet32, text, color, dartPosition - textOffset); }
private void _drawRoundNumbers(SpriteBatch spriteBatch) { var position = new Vector2(20, 260.0f); var smallFont = ScreenManager.Trebuchet22; var text = "Round: "; TextBlock.DrawShadowed(spriteBatch, smallFont, text, Color.LightBlue, position); position.X += smallFont.MeasureString(text).X; text = (_mode.CurrentRoundIndex + 1) + "/" + _mode.MaxRounds; TextBlock.DrawShadowed(spriteBatch, smallFont, text, Color.White, position); position.Y += smallFont.LineSpacing; }
private void drawGameModeName(SpriteBatch spriteBatch) { var position = Vector2.One * 20.0f; var smallFont = ScreenManager.Trebuchet22; var bigFont = ScreenManager.Trebuchet32; var text = "Game Mode:"; TextBlock.DrawShadowed(spriteBatch, smallFont, text, Color.LightBlue, position); position.Y += smallFont.LineSpacing; text = _mode.Name; TextBlock.DrawShadowed(spriteBatch, bigFont, text, Color.White, position); position.Y += bigFont.MeasureString(text).Y; }
public override void Draw(SpriteBatch spriteBatch) { spriteBatch.Begin(); if (_recordManager.Records.Count == 0) { var text = "There are no records saved"; var offset = ScreenManager.Trebuchet24.MeasureString(text); TextBlock.DrawShadowed(spriteBatch, ScreenManager.Trebuchet24, text, Color.White, (new Vector2(XnaDartsGame.Viewport.Width, XnaDartsGame.Viewport.Height) - offset) * 0.5f); } else { drawGraph(spriteBatch); } spriteBatch.End(); base.Draw(spriteBatch); }
public void Draw(SpriteBatch spriteBatch) { _glowAlpha = 1.0f; //(float) (Math.Sin(gameTime.TotalGameTime.TotalSeconds) + 1.0f)/2.0f; var bigFont = ScreenManager.Trebuchet32; var scoreFont = ScreenManager.Trebuchet48; var playerPanelWidth = XnaDartsGame.Viewport.Width / _mode.Players.Count; if (playerPanelWidth > PlayerPanelMaxWidth) { playerPanelWidth = PlayerPanelMaxWidth; } var position = new Vector2(XnaDartsGame.Viewport.Width * 0.5f - _mode.Players.Count / 2.0f * playerPanelWidth, XnaDartsGame.Viewport.Height * 0.8f); var leaders = _mode.GetLeaders(); for (var i = 0; i < _mode.Players.Count; i++) { var text = _mode.Players[i].Name; var nameFont = bigFont; var nameSize = nameFont.MeasureString(text); var background = Color.White * 0.33f; var foreground = Color.White; var shadow = Color.Black; var scoreBackground = _mode.GetPlayerColor(_mode.Players[i]); var namePanelRectangle = new Rectangle((int)position.X, (int)position.Y, playerPanelWidth, (int)nameSize.Y); var score = _mode.GetScore(_mode.Players[i]).ToString(); var scoreSize = scoreFont.MeasureString(score); var y = (int)(position.Y + nameSize.Y); var height = XnaDartsGame.Viewport.Height - y; var scoreRectangle = new Rectangle((int)position.X, y, playerPanelWidth, height); if (_mode.CurrentPlayerIndex == i) { background = Color.White; shadow = Color.White; foreground = _mode.GetPlayerColor(_mode.Players[i]); //Draw glow spriteBatch.Draw(_glow, new Vector2(scoreRectangle.Center.X, scoreRectangle.Center.Y), null, _mode.GetPlayerColor(_mode.Players[i]) * _glowAlpha, 0, new Vector2(_glow.Width, _glow.Height) * 0.5f, 3.0f, SpriteEffects.None, 0); } else { scoreBackground *= 0.33f; } //Draw player name panel spriteBatch.Draw(_playerNameBackground, namePanelRectangle, background); //Draw player name var center = new Vector2(playerPanelWidth, nameSize.Y) * 0.5f; var offset = nameSize * 0.5f; spriteBatch.DrawString(nameFont, text, position + center - offset + Vector2.One, shadow); spriteBatch.DrawString(nameFont, text, position + center - offset, foreground); //Draw score background rectangle spriteBatch.Draw(ScreenManager.BlankTexture, scoreRectangle, scoreBackground); center = new Vector2(playerPanelWidth, height) * 0.5f; offset = scoreSize * 0.5f; //Draw score var scorePos = new Vector2(position.X, y) + center - offset; TextBlock.DrawShadowed(spriteBatch, scoreFont, score, Color.White, scorePos); //Draw crown if (leaders.Contains(_mode.Players[i])) { spriteBatch.Draw(_crown, position + new Vector2(0, nameSize.Y + 10), null, Color.White, 0, Vector2.Zero, 0.5f, SpriteEffects.None, 0); } position.X += playerPanelWidth; } }