From 7eab50b989cca6faa2bb0a696871d254b3ca1eed Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 10 Jan 2017 16:01:53 +0800 Subject: [PATCH 1/3] Add basic HP display support. --- osu.Game/Modes/Score.cs | 1 + osu.Game/Modes/ScoreProcesssor.cs | 5 +++- osu.Game/Modes/UI/HPDisplay.cs | 42 +++++++++++++++++++++++++++++++ osu.Game/Modes/UI/ScoreOverlay.cs | 11 ++++++++ osu.Game/osu.Game.csproj | 3 ++- 5 files changed, 60 insertions(+), 2 deletions(-) create mode 100644 osu.Game/Modes/UI/HPDisplay.cs diff --git a/osu.Game/Modes/Score.cs b/osu.Game/Modes/Score.cs index ee90a9a0f9..b5dcf63028 100644 --- a/osu.Game/Modes/Score.cs +++ b/osu.Game/Modes/Score.cs @@ -15,5 +15,6 @@ namespace osu.Game.Modes public double Accuracy { get; set; } public double Combo { get; set; } public double MaxCombo { get; set; } + public double Health { get; set; } } } diff --git a/osu.Game/Modes/ScoreProcesssor.cs b/osu.Game/Modes/ScoreProcesssor.cs index a34915eaef..b90e24a0ff 100644 --- a/osu.Game/Modes/ScoreProcesssor.cs +++ b/osu.Game/Modes/ScoreProcesssor.cs @@ -18,13 +18,16 @@ namespace osu.Game.Modes TotalScore = TotalScore, Combo = Combo, MaxCombo = HighestCombo, - Accuracy = Accuracy + Accuracy = Accuracy, + Health = Health, }; public readonly BindableDouble TotalScore = new BindableDouble { MinValue = 0 }; public readonly BindableDouble Accuracy = new BindableDouble { MinValue = 0, MaxValue = 1 }; + public readonly BindableDouble Health = new BindableDouble { MinValue = 0, MaxValue = 1 }; + public readonly BindableInt Combo = new BindableInt(); public readonly BindableInt HighestCombo = new BindableInt(); diff --git a/osu.Game/Modes/UI/HPDisplay.cs b/osu.Game/Modes/UI/HPDisplay.cs new file mode 100644 index 0000000000..4cf42f0eb8 --- /dev/null +++ b/osu.Game/Modes/UI/HPDisplay.cs @@ -0,0 +1,42 @@ +using OpenTK; +using OpenTK.Graphics; +using osu.Framework.Configuration; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Sprites; +using osu.Framework.Graphics.Transformations; +using System; + +namespace osu.Game.Modes.UI +{ + public class HPDisplay : Container + { + private Box background; + private Box fill; + + public HPDisplay() + { + Children = new Drawable[] + { + background = new Box + { + RelativeSizeAxes = Axes.Both, + Colour = Color4.Gray, + }, + fill = new Box + { + RelativeSizeAxes = Axes.Both, + Colour = Color4.White, + }, + }; + } + + public double Current; + + public void Set(double value) + { + Current = value; + fill.ScaleTo(new Vector2((float)Current, 1), 200, EasingTypes.OutQuint); + } + } +} diff --git a/osu.Game/Modes/UI/ScoreOverlay.cs b/osu.Game/Modes/UI/ScoreOverlay.cs index c7441483f8..95d74edba5 100644 --- a/osu.Game/Modes/UI/ScoreOverlay.cs +++ b/osu.Game/Modes/UI/ScoreOverlay.cs @@ -6,6 +6,8 @@ using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Game.Graphics.UserInterface; using osu.Game.Modes.Objects; +using OpenTK; +using osu.Framework.Graphics.Primitives; namespace osu.Game.Modes.UI { @@ -15,12 +17,19 @@ namespace osu.Game.Modes.UI public ComboCounter ComboCounter; public ScoreCounter ScoreCounter; public PercentageCounter AccuracyCounter; + public HPDisplay HPDisplay; public Score Score { get; set; } protected abstract KeyCounterCollection CreateKeyCounter(); protected abstract ComboCounter CreateComboCounter(); protected abstract PercentageCounter CreateAccuracyCounter(); protected abstract ScoreCounter CreateScoreCounter(); + protected virtual HPDisplay CreateHPDisplay() => new HPDisplay + { + Size = new Vector2(0.5f, 20), + RelativeSizeAxes = Axes.X, + Padding = new MarginPadding(5) + }; public virtual void OnHit(HitObject h) { @@ -44,6 +53,7 @@ namespace osu.Game.Modes.UI ComboCounter = CreateComboCounter(), ScoreCounter = CreateScoreCounter(), AccuracyCounter = CreateAccuracyCounter(), + HPDisplay = CreateHPDisplay(), }; } @@ -53,6 +63,7 @@ namespace osu.Game.Modes.UI processor.TotalScore.ValueChanged += delegate { ScoreCounter?.Set((ulong)processor.TotalScore.Value); }; processor.Accuracy.ValueChanged += delegate { AccuracyCounter?.Set((float)processor.Accuracy.Value); }; processor.Combo.ValueChanged += delegate { ComboCounter?.Set((ulong)processor.Combo.Value); }; + processor.Health.ValueChanged += delegate { HPDisplay?.Set((ulong)processor.Combo.Value); }; } } } diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index a15cd5db7d..3d3823626f 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -70,6 +70,7 @@ + @@ -259,4 +260,4 @@ --> - + \ No newline at end of file From 1392cdfb9a121e787894a346299c880775684d5d Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 10 Jan 2017 17:21:07 +0800 Subject: [PATCH 2/3] Hook up naively. --- osu.Game.Modes.Osu/OsuScoreProcessor.cs | 2 ++ osu.Game/Modes/UI/HPDisplay.cs | 1 + osu.Game/Modes/UI/ScoreOverlay.cs | 2 +- 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/osu.Game.Modes.Osu/OsuScoreProcessor.cs b/osu.Game.Modes.Osu/OsuScoreProcessor.cs index 572506050b..7da8f763fb 100644 --- a/osu.Game.Modes.Osu/OsuScoreProcessor.cs +++ b/osu.Game.Modes.Osu/OsuScoreProcessor.cs @@ -21,9 +21,11 @@ namespace osu.Game.Modes.Osu { case HitResult.Hit: Combo.Value++; + Health.Value += 0.1f; break; case HitResult.Miss: Combo.Value = 0; + Health.Value -= 0.2f; break; } } diff --git a/osu.Game/Modes/UI/HPDisplay.cs b/osu.Game/Modes/UI/HPDisplay.cs index 4cf42f0eb8..316d8c40d2 100644 --- a/osu.Game/Modes/UI/HPDisplay.cs +++ b/osu.Game/Modes/UI/HPDisplay.cs @@ -27,6 +27,7 @@ namespace osu.Game.Modes.UI { RelativeSizeAxes = Axes.Both, Colour = Color4.White, + Scale = new Vector2(0, 1), }, }; } diff --git a/osu.Game/Modes/UI/ScoreOverlay.cs b/osu.Game/Modes/UI/ScoreOverlay.cs index 95d74edba5..69b1119264 100644 --- a/osu.Game/Modes/UI/ScoreOverlay.cs +++ b/osu.Game/Modes/UI/ScoreOverlay.cs @@ -63,7 +63,7 @@ namespace osu.Game.Modes.UI processor.TotalScore.ValueChanged += delegate { ScoreCounter?.Set((ulong)processor.TotalScore.Value); }; processor.Accuracy.ValueChanged += delegate { AccuracyCounter?.Set((float)processor.Accuracy.Value); }; processor.Combo.ValueChanged += delegate { ComboCounter?.Set((ulong)processor.Combo.Value); }; - processor.Health.ValueChanged += delegate { HPDisplay?.Set((ulong)processor.Combo.Value); }; + processor.Health.ValueChanged += delegate { HPDisplay?.Set(processor.Health.Value); }; } } } From cd8c9393f3205a69c367545742f7c47e48f82219 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 18 Jan 2017 11:08:16 +0800 Subject: [PATCH 3/3] HP -> Health --- osu.Game/Modes/UI/{HPDisplay.cs => HealthDisplay.cs} | 4 ++-- osu.Game/Modes/UI/ScoreOverlay.cs | 8 ++++---- osu.Game/osu.Game.csproj | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) rename osu.Game/Modes/UI/{HPDisplay.cs => HealthDisplay.cs} (89%) diff --git a/osu.Game/Modes/UI/HPDisplay.cs b/osu.Game/Modes/UI/HealthDisplay.cs similarity index 89% rename from osu.Game/Modes/UI/HPDisplay.cs rename to osu.Game/Modes/UI/HealthDisplay.cs index 316d8c40d2..0645d54b50 100644 --- a/osu.Game/Modes/UI/HPDisplay.cs +++ b/osu.Game/Modes/UI/HealthDisplay.cs @@ -9,12 +9,12 @@ using System; namespace osu.Game.Modes.UI { - public class HPDisplay : Container + public class HealthDisplay : Container { private Box background; private Box fill; - public HPDisplay() + public HealthDisplay() { Children = new Drawable[] { diff --git a/osu.Game/Modes/UI/ScoreOverlay.cs b/osu.Game/Modes/UI/ScoreOverlay.cs index 69b1119264..fbdd75b97d 100644 --- a/osu.Game/Modes/UI/ScoreOverlay.cs +++ b/osu.Game/Modes/UI/ScoreOverlay.cs @@ -17,14 +17,14 @@ namespace osu.Game.Modes.UI public ComboCounter ComboCounter; public ScoreCounter ScoreCounter; public PercentageCounter AccuracyCounter; - public HPDisplay HPDisplay; + public HealthDisplay HealthDisplay; public Score Score { get; set; } protected abstract KeyCounterCollection CreateKeyCounter(); protected abstract ComboCounter CreateComboCounter(); protected abstract PercentageCounter CreateAccuracyCounter(); protected abstract ScoreCounter CreateScoreCounter(); - protected virtual HPDisplay CreateHPDisplay() => new HPDisplay + protected virtual HealthDisplay CreateHealthDisplay() => new HealthDisplay { Size = new Vector2(0.5f, 20), RelativeSizeAxes = Axes.X, @@ -53,7 +53,7 @@ namespace osu.Game.Modes.UI ComboCounter = CreateComboCounter(), ScoreCounter = CreateScoreCounter(), AccuracyCounter = CreateAccuracyCounter(), - HPDisplay = CreateHPDisplay(), + HealthDisplay = CreateHealthDisplay(), }; } @@ -63,7 +63,7 @@ namespace osu.Game.Modes.UI processor.TotalScore.ValueChanged += delegate { ScoreCounter?.Set((ulong)processor.TotalScore.Value); }; processor.Accuracy.ValueChanged += delegate { AccuracyCounter?.Set((float)processor.Accuracy.Value); }; processor.Combo.ValueChanged += delegate { ComboCounter?.Set((ulong)processor.Combo.Value); }; - processor.Health.ValueChanged += delegate { HPDisplay?.Set(processor.Health.Value); }; + processor.Health.ValueChanged += delegate { HealthDisplay?.Set(processor.Health.Value); }; } } } diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index d1be695e15..8843bcf219 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -70,7 +70,7 @@ - +