Category5.HealthBar.Draw C# (CSharp) Method

Draw() public static method

public static Draw ( Rectangle rectangle, Color FullColour, Color MidColour, Color LowColour, float percent ) : void
rectangle Microsoft.Xna.Framework.Rectangle
FullColour Color
MidColour Color
LowColour Color
percent float
return void
        public static void Draw(Rectangle rectangle, Color FullColour, Color MidColour, Color LowColour, float percent)
        {
            location.X = rectangle.X;
            location.Y = rectangle.Y;

            width = rectangle.Width;
            height = rectangle.Height;

            Color color;

            if (percent > 0.60f)
            {
                color = FullColour;
            }
            else if (percent > 0.30f)
            {
                color = MidColour;
            }
            else
            {
                color = LowColour;
            }

            //Outlining black rectangle
            game.spriteBatch.Draw(blank, rectangle, new Color(0, 0, 0, 128));
            //Colored bar
            game.spriteBatch.Draw(blank, new Rectangle(rectangle.X + 1, rectangle.Y + 1, Convert.ToInt16(rectangle.Width * percent) - 2, rectangle.Height - 2), color);
            //Background bar
            game.spriteBatch.Draw(blank, new Rectangle(rectangle.X + Convert.ToInt16(rectangle.Width * percent), rectangle.Y + 1, Convert.ToInt16(rectangle.Width * (1 - percent)) - 1, rectangle.Height - 2), new Color(128, 128, 255, 128));
        }

Same methods

HealthBar::Draw ( Rectangle rectangle, float percent ) : void