osu/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-03-02 09:45:20 +00:00
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
2017-02-16 13:44:21 +00:00
using System;
using osu.Framework.Allocation;
2017-01-10 08:01:53 +00:00
using osu.Framework.Configuration;
using osu.Framework.Extensions.Color4Extensions;
2017-01-10 08:01:53 +00:00
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Sprites;
2017-02-25 12:12:39 +00:00
using osu.Framework.Graphics.Transforms;
2017-02-16 13:44:21 +00:00
using osu.Game.Graphics;
using OpenTK;
using OpenTK.Graphics;
2017-01-10 08:01:53 +00:00
namespace osu.Game.Modes.UI
{
2017-01-18 03:08:16 +00:00
public class HealthDisplay : Container
2017-01-10 08:01:53 +00:00
{
2017-02-16 13:44:21 +00:00
private Container fill;
2017-01-10 08:01:53 +00:00
2017-03-07 01:59:19 +00:00
public BindableDouble Current = new BindableDouble
2017-02-16 13:44:21 +00:00
{
MinValue = 0,
MaxValue = 1
};
2017-01-18 05:40:13 +00:00
2017-01-18 03:08:16 +00:00
public HealthDisplay()
2017-01-10 08:01:53 +00:00
{
Children = new Drawable[]
{
2017-03-07 01:59:19 +00:00
new Box
2017-01-10 08:01:53 +00:00
{
RelativeSizeAxes = Axes.Both,
2017-02-16 13:44:21 +00:00
Colour = Color4.Black,
2017-01-10 08:01:53 +00:00
},
2017-02-16 13:44:21 +00:00
fill = new Container
2017-01-10 08:01:53 +00:00
{
RelativeSizeAxes = Axes.Both,
2017-01-10 09:21:07 +00:00
Scale = new Vector2(0, 1),
2017-02-16 13:44:21 +00:00
Masking = true,
Children = new[]
{
new Box
{
RelativeSizeAxes = Axes.Both,
}
}
},
2017-01-10 08:01:53 +00:00
};
2017-01-18 05:40:13 +00:00
Current.ValueChanged += current_ValueChanged;
}
2017-01-10 08:01:53 +00:00
2017-02-16 13:44:21 +00: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 05:40:13 +00:00
private void current_ValueChanged(object sender, EventArgs e)
2017-01-10 08:01:53 +00:00
{
fill.ScaleTo(new Vector2((float)Current, 1), 200, EasingTypes.OutQuint);
}
}
}