PathfindingTest.Units.HealthBar.Draw C# (CSharp) Method

Draw() private method

private Draw ( SpriteBatch sb ) : void
sb Microsoft.Xna.Framework.Graphics.SpriteBatch
return void
        internal void Draw(SpriteBatch sb)
        {
            int w;
            int h;
            int x;
            int y;
            int innerWidth;

            Vector2 offset = Game1.GetInstance().drawOffset;

            switch (type)
            {
                case Type.Building:
                    w = building.texture.Width;
                    h = 5;
                    x = (int)(building.x - 1 - offset.X);
                    y = (int)(building.y - h * 2 - offset.Y);
                    innerWidth = (int)((w / 100.0) * percentage);
                    break;

                case Type.Unit:
                    w = unit.texture.Width;
                    h = 5;
                    x = (int)(unit.x - (w / 2) - offset.X);
                    y = (int)(unit.y - (unit.texture.Height / 2) - h - offset.Y);
                    innerWidth = (int)((w / 100.0) * percentage);
                    break;

                default:
                    return;
            }

            sb.Draw(this.texture, new Rectangle(x, y,
                w + 2, h), null, BORDER_COLOR, 0f, Vector2.Zero, SpriteEffects.None, z);

            sb.Draw(this.texture, new Rectangle(x + 1, y + 1,
                w, h - 2), null, BACKGROUND_COLOR, 0f, Vector2.Zero, SpriteEffects.None, z - 0.0001f);

            Color foreground = Color.Gold;
            if (this.useDynamicColoring)
            {
                foreground = this.GetDynamicColor();
            }
            else foreground = FOREGROUND_COLOR;

            sb.Draw(this.texture, new Rectangle(x + 1, y + 1,
                innerWidth, h - 2), null, foreground, 0f, Vector2.Zero, SpriteEffects.None, z - 0.0002f);

            /*
            sb.Draw(texture, new Rectangle(x, y, w + 2, h), BORDER_COLOR);
            sb.Draw(texture, new Rectangle(x + 1, y + 1, w, h - 2), BACKGROUND_COLOR);
            sb.Draw(texture, new Rectangle(x + 1, y + 1, innerWidth, h - 2), FOREGROUND_COLOR);*/
        }