1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-12 02:27:25 +08:00
osu-lazer/osu.Game/Modes/UI/HealthDisplay.cs

73 lines
2.1 KiB
C#
Raw Normal View History

// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
2017-02-16 21:44:21 +08:00
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu-framework/master/LICENCE
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;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.Transformations;
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);
}
}
}