2017-02-07 12:59:30 +08:00
|
|
|
|
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
2017-03-02 17:45:20 +08:00
|
|
|
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
2017-02-07 12:59:30 +08:00
|
|
|
|
|
2017-02-16 21:44:21 +08:00
|
|
|
|
using System;
|
|
|
|
|
using osu.Framework.Allocation;
|
2017-01-10 16:01:53 +08:00
|
|
|
|
using osu.Framework.Configuration;
|
2017-03-05 02:42:37 +08:00
|
|
|
|
using osu.Framework.Extensions.Color4Extensions;
|
2017-01-10 16:01:53 +08:00
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
|
using osu.Framework.Graphics.Sprites;
|
2017-02-25 20:12:39 +08:00
|
|
|
|
using osu.Framework.Graphics.Transforms;
|
2017-02-16 21:44:21 +08:00
|
|
|
|
using osu.Game.Graphics;
|
|
|
|
|
using OpenTK;
|
|
|
|
|
using OpenTK.Graphics;
|
2017-01-10 16:01:53 +08:00
|
|
|
|
|
|
|
|
|
namespace osu.Game.Modes.UI
|
|
|
|
|
{
|
2017-01-18 11:08:16 +08:00
|
|
|
|
public class HealthDisplay : Container
|
2017-01-10 16:01:53 +08:00
|
|
|
|
{
|
|
|
|
|
private Box background;
|
2017-02-16 21:44:21 +08:00
|
|
|
|
private Container fill;
|
2017-01-10 16:01:53 +08:00
|
|
|
|
|
2017-02-16 21:44:21 +08:00
|
|
|
|
public BindableDouble Current = new BindableDouble()
|
|
|
|
|
{
|
|
|
|
|
MinValue = 0,
|
|
|
|
|
MaxValue = 1
|
|
|
|
|
};
|
2017-01-18 13:40:13 +08:00
|
|
|
|
|
2017-01-18 11:08:16 +08:00
|
|
|
|
public HealthDisplay()
|
2017-01-10 16:01:53 +08:00
|
|
|
|
{
|
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
|
|
|
|
background = new Box
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
2017-02-16 21:44:21 +08:00
|
|
|
|
Colour = Color4.Black,
|
2017-01-10 16:01:53 +08:00
|
|
|
|
},
|
2017-02-16 21:44:21 +08:00
|
|
|
|
fill = new Container
|
2017-01-10 16:01:53 +08:00
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
2017-01-10 17:21:07 +08:00
|
|
|
|
Scale = new Vector2(0, 1),
|
2017-02-16 21:44:21 +08:00
|
|
|
|
Masking = true,
|
|
|
|
|
Children = new[]
|
|
|
|
|
{
|
|
|
|
|
new Box
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
},
|
2017-01-10 16:01:53 +08:00
|
|
|
|
};
|
|
|
|
|
|
2017-01-18 13:40:13 +08:00
|
|
|
|
Current.ValueChanged += current_ValueChanged;
|
|
|
|
|
}
|
2017-01-10 16:01:53 +08:00
|
|
|
|
|
2017-02-16 21:44:21 +08:00
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
|
private void laod(OsuColour colours)
|
|
|
|
|
{
|
|
|
|
|
fill.Colour = colours.BlueLighter;
|
|
|
|
|
fill.EdgeEffect = new EdgeEffect
|
|
|
|
|
{
|
|
|
|
|
Colour = colours.BlueDarker.Opacity(0.6f),
|
|
|
|
|
Radius = 8,
|
|
|
|
|
Type= EdgeEffectType.Glow
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
2017-01-18 13:40:13 +08:00
|
|
|
|
private void current_ValueChanged(object sender, EventArgs e)
|
2017-01-10 16:01:53 +08:00
|
|
|
|
{
|
|
|
|
|
fill.ScaleTo(new Vector2((float)Current, 1), 200, EasingTypes.OutQuint);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|