Bricklayer.Client.Entities.Player.DrawTag C# (CSharp) Method

DrawTag() private method

Draws the players username above them
private DrawTag ( SpriteBatch spriteBatch, float elapsed ) : void
spriteBatch Microsoft.Xna.Framework.Graphics.SpriteBatch
elapsed float
return void
        private void DrawTag(SpriteBatch spriteBatch, float elapsed)
        {
            //Draw Tag and calculate it's color
            bool showTag = Game.Input.AnyKeysDown(Keys.LeftAlt, Keys.RightAlt);
            if (IdleTime > 1.5f)
                tagAlpha += elapsed * 2;
            else
                tagAlpha -= elapsed * 8;
            if (tagAlpha > 0 || showTag)
            {
                float alpha = showTag ? 1f : tagAlpha;
                int tagWidth = (int)Game.MainWindow.Manager.Skin.Fonts["Default8"].Resource.MeasureString(Username).X / 2;
                //Draw one white tag, and 8 shadow tags
                for (int x = -1; x <= 1; x++)
                {
                    for (int y = -1; y <= 1; y++)
                    {
                        if (!(x == 0 && y == 0))
                        {
                            spriteBatch.DrawString(Game.DefaultFont, Username, new Vector2((float)Math.Round(DisplayState.Position.X) - tagWidth + (Width / 2) + x, (float)Math.Round(DisplayState.Position.Y) - Height + y), Color.Black * .4f * alpha);
                        }
                    }
                }
                spriteBatch.DrawString(Game.DefaultFont, Username, new Vector2((float)Math.Round(DisplayState.Position.X) - tagWidth + (Width / 2), (float)Math.Round(DisplayState.Position.Y) - Height), Color.White * alpha);
            }
            tagAlpha = MathHelper.Clamp(tagAlpha, 0, 1);
        }