mirror of
https://github.com/ppy/osu.git
synced 2024-09-22 18:07:24 +08:00
Merge pull request #288 from peppy/hpdisplay
Simple HP display implementation.
This commit is contained in:
commit
2025e8ef71
@ -21,9 +21,11 @@ namespace osu.Game.Modes.Osu
|
|||||||
{
|
{
|
||||||
case HitResult.Hit:
|
case HitResult.Hit:
|
||||||
Combo.Value++;
|
Combo.Value++;
|
||||||
|
Health.Value += 0.1f;
|
||||||
break;
|
break;
|
||||||
case HitResult.Miss:
|
case HitResult.Miss:
|
||||||
Combo.Value = 0;
|
Combo.Value = 0;
|
||||||
|
Health.Value -= 0.2f;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,5 +15,6 @@ namespace osu.Game.Modes
|
|||||||
public double Accuracy { get; set; }
|
public double Accuracy { get; set; }
|
||||||
public double Combo { get; set; }
|
public double Combo { get; set; }
|
||||||
public double MaxCombo { get; set; }
|
public double MaxCombo { get; set; }
|
||||||
|
public double Health { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,13 +18,16 @@ namespace osu.Game.Modes
|
|||||||
TotalScore = TotalScore,
|
TotalScore = TotalScore,
|
||||||
Combo = Combo,
|
Combo = Combo,
|
||||||
MaxCombo = HighestCombo,
|
MaxCombo = HighestCombo,
|
||||||
Accuracy = Accuracy
|
Accuracy = Accuracy,
|
||||||
|
Health = Health,
|
||||||
};
|
};
|
||||||
|
|
||||||
public readonly BindableDouble TotalScore = new BindableDouble { MinValue = 0 };
|
public readonly BindableDouble TotalScore = new BindableDouble { MinValue = 0 };
|
||||||
|
|
||||||
public readonly BindableDouble Accuracy = new BindableDouble { MinValue = 0, MaxValue = 1 };
|
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 Combo = new BindableInt();
|
||||||
|
|
||||||
public readonly BindableInt HighestCombo = new BindableInt();
|
public readonly BindableInt HighestCombo = new BindableInt();
|
||||||
|
43
osu.Game/Modes/UI/HealthDisplay.cs
Normal file
43
osu.Game/Modes/UI/HealthDisplay.cs
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
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 HealthDisplay : Container
|
||||||
|
{
|
||||||
|
private Box background;
|
||||||
|
private Box fill;
|
||||||
|
|
||||||
|
public HealthDisplay()
|
||||||
|
{
|
||||||
|
Children = new Drawable[]
|
||||||
|
{
|
||||||
|
background = new Box
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
Colour = Color4.Gray,
|
||||||
|
},
|
||||||
|
fill = new Box
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
Colour = Color4.White,
|
||||||
|
Scale = new Vector2(0, 1),
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public double Current;
|
||||||
|
|
||||||
|
public void Set(double value)
|
||||||
|
{
|
||||||
|
Current = value;
|
||||||
|
fill.ScaleTo(new Vector2((float)Current, 1), 200, EasingTypes.OutQuint);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -6,6 +6,8 @@ using osu.Framework.Graphics;
|
|||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Game.Graphics.UserInterface;
|
using osu.Game.Graphics.UserInterface;
|
||||||
using osu.Game.Modes.Objects;
|
using osu.Game.Modes.Objects;
|
||||||
|
using OpenTK;
|
||||||
|
using osu.Framework.Graphics.Primitives;
|
||||||
|
|
||||||
namespace osu.Game.Modes.UI
|
namespace osu.Game.Modes.UI
|
||||||
{
|
{
|
||||||
@ -15,12 +17,19 @@ namespace osu.Game.Modes.UI
|
|||||||
public ComboCounter ComboCounter;
|
public ComboCounter ComboCounter;
|
||||||
public ScoreCounter ScoreCounter;
|
public ScoreCounter ScoreCounter;
|
||||||
public PercentageCounter AccuracyCounter;
|
public PercentageCounter AccuracyCounter;
|
||||||
|
public HealthDisplay HealthDisplay;
|
||||||
public Score Score { get; set; }
|
public Score Score { get; set; }
|
||||||
|
|
||||||
protected abstract KeyCounterCollection CreateKeyCounter();
|
protected abstract KeyCounterCollection CreateKeyCounter();
|
||||||
protected abstract ComboCounter CreateComboCounter();
|
protected abstract ComboCounter CreateComboCounter();
|
||||||
protected abstract PercentageCounter CreateAccuracyCounter();
|
protected abstract PercentageCounter CreateAccuracyCounter();
|
||||||
protected abstract ScoreCounter CreateScoreCounter();
|
protected abstract ScoreCounter CreateScoreCounter();
|
||||||
|
protected virtual HealthDisplay CreateHealthDisplay() => new HealthDisplay
|
||||||
|
{
|
||||||
|
Size = new Vector2(0.5f, 20),
|
||||||
|
RelativeSizeAxes = Axes.X,
|
||||||
|
Padding = new MarginPadding(5)
|
||||||
|
};
|
||||||
|
|
||||||
public virtual void OnHit(HitObject h)
|
public virtual void OnHit(HitObject h)
|
||||||
{
|
{
|
||||||
@ -44,6 +53,7 @@ namespace osu.Game.Modes.UI
|
|||||||
ComboCounter = CreateComboCounter(),
|
ComboCounter = CreateComboCounter(),
|
||||||
ScoreCounter = CreateScoreCounter(),
|
ScoreCounter = CreateScoreCounter(),
|
||||||
AccuracyCounter = CreateAccuracyCounter(),
|
AccuracyCounter = CreateAccuracyCounter(),
|
||||||
|
HealthDisplay = CreateHealthDisplay(),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -53,6 +63,7 @@ namespace osu.Game.Modes.UI
|
|||||||
processor.TotalScore.ValueChanged += delegate { ScoreCounter?.Set((ulong)processor.TotalScore.Value); };
|
processor.TotalScore.ValueChanged += delegate { ScoreCounter?.Set((ulong)processor.TotalScore.Value); };
|
||||||
processor.Accuracy.ValueChanged += delegate { AccuracyCounter?.Set((float)processor.Accuracy.Value); };
|
processor.Accuracy.ValueChanged += delegate { AccuracyCounter?.Set((float)processor.Accuracy.Value); };
|
||||||
processor.Combo.ValueChanged += delegate { ComboCounter?.Set((ulong)processor.Combo.Value); };
|
processor.Combo.ValueChanged += delegate { ComboCounter?.Set((ulong)processor.Combo.Value); };
|
||||||
|
processor.Health.ValueChanged += delegate { HealthDisplay?.Set(processor.Health.Value); };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -70,6 +70,7 @@
|
|||||||
<Compile Include="Modes\Objects\HitObjectParser.cs" />
|
<Compile Include="Modes\Objects\HitObjectParser.cs" />
|
||||||
<Compile Include="Modes\Score.cs" />
|
<Compile Include="Modes\Score.cs" />
|
||||||
<Compile Include="Modes\ScoreProcesssor.cs" />
|
<Compile Include="Modes\ScoreProcesssor.cs" />
|
||||||
|
<Compile Include="Modes\UI\HealthDisplay.cs" />
|
||||||
<Compile Include="Online\API\IOnlineComponent.cs" />
|
<Compile Include="Online\API\IOnlineComponent.cs" />
|
||||||
<Compile Include="Online\API\Requests\GetUserRequest.cs" />
|
<Compile Include="Online\API\Requests\GetUserRequest.cs" />
|
||||||
<Compile Include="Overlays\DragBar.cs" />
|
<Compile Include="Overlays\DragBar.cs" />
|
||||||
@ -260,4 +261,4 @@
|
|||||||
<Target Name="AfterBuild">
|
<Target Name="AfterBuild">
|
||||||
</Target>
|
</Target>
|
||||||
-->
|
-->
|
||||||
</Project>
|
</Project>
|
Loading…
Reference in New Issue
Block a user