2017-03-10 11:26:46 +08:00
|
|
|
|
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
|
|
|
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
|
|
|
|
|
|
|
|
|
using OpenTK;
|
|
|
|
|
using OpenTK.Graphics;
|
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
|
using osu.Framework.Graphics.Sprites;
|
|
|
|
|
using osu.Game.Graphics;
|
|
|
|
|
|
2017-04-18 15:05:58 +08:00
|
|
|
|
namespace osu.Game.Rulesets.UI
|
2017-03-10 11:26:46 +08:00
|
|
|
|
{
|
2017-04-13 09:04:12 +08:00
|
|
|
|
public class StandardHealthDisplay : HealthDisplay, IHasAccentColour
|
2017-03-10 11:26:46 +08:00
|
|
|
|
{
|
2017-03-23 12:41:50 +08:00
|
|
|
|
private readonly Container fill;
|
2017-03-10 11:26:46 +08:00
|
|
|
|
|
2017-04-13 09:04:12 +08:00
|
|
|
|
public Color4 AccentColour
|
|
|
|
|
{
|
|
|
|
|
get { return fill.Colour; }
|
|
|
|
|
set { fill.Colour = value; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private Color4 glowColour;
|
|
|
|
|
public Color4 GlowColour
|
|
|
|
|
{
|
|
|
|
|
get { return glowColour; }
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
if (glowColour == value)
|
|
|
|
|
return;
|
|
|
|
|
glowColour = value;
|
|
|
|
|
|
|
|
|
|
fill.EdgeEffect = new EdgeEffect
|
|
|
|
|
{
|
|
|
|
|
Colour = glowColour,
|
|
|
|
|
Radius = 8,
|
2017-04-20 16:11:15 +08:00
|
|
|
|
Roundness = 4,
|
|
|
|
|
Type = EdgeEffectType.Glow,
|
2017-04-13 09:04:12 +08:00
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-03-10 11:26:46 +08:00
|
|
|
|
public StandardHealthDisplay()
|
|
|
|
|
{
|
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
|
|
|
|
new Box
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
Colour = Color4.Black,
|
|
|
|
|
},
|
|
|
|
|
fill = new Container
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
2017-04-20 16:11:15 +08:00
|
|
|
|
Size = new Vector2(0, 1),
|
2017-03-10 11:26:46 +08:00
|
|
|
|
Masking = true,
|
|
|
|
|
Children = new[]
|
|
|
|
|
{
|
|
|
|
|
new Box
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
2017-04-20 16:11:15 +08:00
|
|
|
|
protected override void SetHealth(float value) => fill.ResizeTo(new Vector2(value, 1), 200, EasingTypes.OutQuint);
|
2017-03-10 11:26:46 +08:00
|
|
|
|
}
|
|
|
|
|
}
|