Move implementation to HUD

This commit is contained in:
Dean Herbert
2020-04-09 14:31:25 +09:00
parent 0e2d5213ce
commit 4976f80b71
6 changed files with 19 additions and 21 deletions

View File

@ -9,6 +9,7 @@ using osu.Framework.Graphics.Shapes;
using osu.Framework.Utils;
using osu.Game.Configuration;
using osu.Game.Graphics;
using osu.Game.Rulesets.Scoring;
namespace osu.Game.Screens.Play.HUD
{
@ -48,6 +49,17 @@ namespace osu.Game.Screens.Play.HUD
enabled.BindValueChanged(e => this.FadeTo(e.NewValue ? 1 : 0, fade_time, Easing.OutQuint), true);
}
public override void BindHealthProcessor(HealthProcessor processor)
{
base.BindHealthProcessor(processor);
if (!(processor is DrainingHealthProcessor))
{
enabled.UnbindBindings();
enabled.Value = false;
}
}
protected override void Update()
{
box.Alpha = (float)Interpolation.ValueAt(Math.Clamp(Clock.ElapsedFrameTime, 0, fade_time), box.Alpha,

View File

@ -23,7 +23,7 @@ namespace osu.Game.Screens.Play.HUD
/// <summary>
/// Bind the tracked fields of <see cref="HealthProcessor"/> to this health display.
/// </summary>
public void BindHealthProcessor(HealthProcessor processor)
public virtual void BindHealthProcessor(HealthProcessor processor)
{
Current.BindTo(processor.Health);
}

View File

@ -37,6 +37,7 @@ namespace osu.Game.Screens.Play
public readonly HitErrorDisplay HitErrorDisplay;
public readonly HoldForMenuButton HoldToQuit;
public readonly PlayerSettingsOverlay PlayerSettingsOverlay;
public readonly FailingLayer FailingLayer;
public Bindable<bool> ShowHealthbar = new Bindable<bool>(true);
@ -75,6 +76,7 @@ namespace osu.Game.Screens.Play
Children = new Drawable[]
{
FailingLayer = CreateFailingLayer(),
visibilityContainer = new Container
{
RelativeSizeAxes = Axes.Both,
@ -260,6 +262,8 @@ namespace osu.Game.Screens.Play
Margin = new MarginPadding { Top = 20 }
};
protected virtual FailingLayer CreateFailingLayer() => new FailingLayer();
protected virtual KeyCounterDisplay CreateKeyCounter() => new KeyCounterDisplay
{
Anchor = Anchor.BottomRight,
@ -304,7 +308,8 @@ namespace osu.Game.Screens.Play
protected virtual void BindHealthProcessor(HealthProcessor processor)
{
HealthDisplay?.Current.BindTo(processor.Health);
HealthDisplay?.BindHealthProcessor(processor);
FailingLayer?.BindHealthProcessor(processor);
}
}
}