diff --git a/osu.Game/Screens/Play/HUD/ArgonHealthDisplay.cs b/osu.Game/Screens/Play/HUD/ArgonHealthDisplay.cs index 6cf1daa102..68685d7eb5 100644 --- a/osu.Game/Screens/Play/HUD/ArgonHealthDisplay.cs +++ b/osu.Game/Screens/Play/HUD/ArgonHealthDisplay.cs @@ -212,7 +212,7 @@ namespace osu.Game.Screens.Play.HUD } } - private double missBarValue = 1.0; + private double missBarValue; private readonly List missBarVertices = new List(); public double MissBarValue @@ -228,7 +228,7 @@ namespace osu.Game.Screens.Play.HUD } } - private double healthBarValue = 1.0; + private double healthBarValue; private readonly List healthBarVertices = new List(); public double HealthBarValue diff --git a/osu.Game/Screens/Play/HUD/HealthDisplay.cs b/osu.Game/Screens/Play/HUD/HealthDisplay.cs index 5131f93ca2..e4bb91e7ca 100644 --- a/osu.Game/Screens/Play/HUD/HealthDisplay.cs +++ b/osu.Game/Screens/Play/HUD/HealthDisplay.cs @@ -6,7 +6,9 @@ using osu.Framework.Bindables; using osu.Framework.Extensions.ObjectExtensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; +using osu.Framework.Threading; using osu.Game.Rulesets.Judgements; +using osu.Game.Rulesets.Objects; using osu.Game.Rulesets.Scoring; using osu.Game.Rulesets.UI; @@ -23,12 +25,16 @@ namespace osu.Game.Screens.Play.HUD [Resolved] protected HealthProcessor HealthProcessor { get; private set; } = null!; - public Bindable Current { get; } = new BindableDouble(1) + public Bindable Current { get; } = new BindableDouble { MinValue = 0, MaxValue = 1 }; + private BindableNumber health = null!; + + private ScheduledDelegate? initialIncrease; + /// /// Triggered when a is a successful hit, signaling the health display to perform a flash animation (if designed to do so). /// @@ -52,14 +58,46 @@ namespace osu.Game.Screens.Play.HUD { base.LoadComplete(); - Current.BindTo(HealthProcessor.Health); HealthProcessor.NewJudgement += onNewJudgement; + // Don't bind directly so we can animate the startup procedure. + health = HealthProcessor.Health.GetBoundCopy(); + health.BindValueChanged(h => + { + Current.Value = h.NewValue; + finishInitialAnimation(); + }); + if (hudOverlay != null) showHealthBar.BindTo(hudOverlay.ShowHealthBar); // this probably shouldn't be operating on `this.` showHealthBar.BindValueChanged(healthBar => this.FadeTo(healthBar.NewValue ? 1 : 0, HUDOverlay.FADE_DURATION, HUDOverlay.FADE_EASING), true); + + startInitialAnimation(); + } + + private void startInitialAnimation() + { + // TODO: this should run in gameplay time, including showing a larger increase when skipping. + // TODO: it should also start increasing relative to the first hitobject. + const double increase_delay = 150; + + initialIncrease = Scheduler.AddDelayed(() => + { + double newValue = Current.Value + 0.05f; + this.TransformBindableTo(Current, newValue, increase_delay); + Flash(new JudgementResult(new HitObject(), new Judgement())); + + if (newValue >= 1) + finishInitialAnimation(); + }, increase_delay, true); + } + + private void finishInitialAnimation() + { + initialIncrease?.Cancel(); + initialIncrease = null; } private void onNewJudgement(JudgementResult judgement) diff --git a/osu.Game/Skinning/LegacyHealthDisplay.cs b/osu.Game/Skinning/LegacyHealthDisplay.cs index f785022f84..08add79fc1 100644 --- a/osu.Game/Skinning/LegacyHealthDisplay.cs +++ b/osu.Game/Skinning/LegacyHealthDisplay.cs @@ -66,6 +66,7 @@ namespace osu.Game.Skinning marker.Current.BindTo(Current); maxFillWidth = fill.Width; + fill.Width = 0; } protected override void Update()