2023-06-23 00:37:25 +08:00
|
|
|
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
2021-06-01 14:57:43 +08:00
|
|
|
|
// See the LICENCE file in the repository root for full licence text.
|
|
|
|
|
|
|
|
|
|
using NUnit.Framework;
|
|
|
|
|
using osu.Framework.Allocation;
|
2021-06-01 15:16:01 +08:00
|
|
|
|
using osu.Framework.Graphics;
|
2021-06-01 14:57:43 +08:00
|
|
|
|
using osu.Framework.Testing;
|
|
|
|
|
using osu.Game.Rulesets.Judgements;
|
2023-10-01 05:20:53 +08:00
|
|
|
|
using osu.Game.Rulesets.Objects;
|
2021-06-01 14:57:43 +08:00
|
|
|
|
using osu.Game.Rulesets.Osu.Judgements;
|
|
|
|
|
using osu.Game.Rulesets.Osu.Objects;
|
|
|
|
|
using osu.Game.Rulesets.Scoring;
|
2021-06-01 15:16:01 +08:00
|
|
|
|
using osu.Game.Screens.Play.HUD;
|
2021-06-01 14:57:43 +08:00
|
|
|
|
using osu.Game.Skinning;
|
2023-10-02 15:07:45 +08:00
|
|
|
|
using osuTK;
|
2021-06-01 14:57:43 +08:00
|
|
|
|
|
|
|
|
|
namespace osu.Game.Tests.Visual.Gameplay
|
|
|
|
|
{
|
2022-11-24 13:32:20 +08:00
|
|
|
|
public partial class TestSceneSkinnableHealthDisplay : SkinnableHUDComponentTestScene
|
2021-06-01 14:57:43 +08:00
|
|
|
|
{
|
|
|
|
|
[Cached(typeof(HealthProcessor))]
|
|
|
|
|
private HealthProcessor healthProcessor = new DrainingHealthProcessor(0);
|
|
|
|
|
|
2023-11-12 06:42:41 +08:00
|
|
|
|
protected override Drawable CreateArgonImplementation() => new ArgonHealthDisplay { Scale = new Vector2(0.6f), Width = 1f };
|
2023-10-02 15:07:45 +08:00
|
|
|
|
protected override Drawable CreateDefaultImplementation() => new DefaultHealthDisplay { Scale = new Vector2(0.6f) };
|
|
|
|
|
protected override Drawable CreateLegacyImplementation() => new LegacyHealthDisplay { Scale = new Vector2(0.6f) };
|
2021-06-01 15:16:01 +08:00
|
|
|
|
|
2021-06-01 14:57:43 +08:00
|
|
|
|
[SetUpSteps]
|
|
|
|
|
public void SetUpSteps()
|
|
|
|
|
{
|
|
|
|
|
AddStep(@"Reset all", delegate
|
|
|
|
|
{
|
|
|
|
|
healthProcessor.Health.Value = 1;
|
2023-10-01 05:20:53 +08:00
|
|
|
|
healthProcessor.Failed += () => false; // health won't be updated if the processor gets into a "fail" state.
|
2021-06-01 14:57:43 +08:00
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void TestHealthDisplayIncrementing()
|
|
|
|
|
{
|
2023-10-01 05:20:53 +08:00
|
|
|
|
AddRepeatStep("apply miss judgement", delegate
|
2021-06-01 14:57:43 +08:00
|
|
|
|
{
|
2023-10-01 05:20:53 +08:00
|
|
|
|
healthProcessor.ApplyResult(new JudgementResult(new HitObject(), new Judgement()) { Type = HitResult.Miss });
|
|
|
|
|
}, 5);
|
|
|
|
|
|
|
|
|
|
AddRepeatStep(@"decrease hp slightly", delegate
|
|
|
|
|
{
|
|
|
|
|
healthProcessor.Health.Value -= 0.01f;
|
2021-06-01 14:57:43 +08:00
|
|
|
|
}, 10);
|
|
|
|
|
|
|
|
|
|
AddRepeatStep(@"increase hp without flash", delegate
|
|
|
|
|
{
|
|
|
|
|
healthProcessor.Health.Value += 0.1f;
|
|
|
|
|
}, 3);
|
|
|
|
|
|
|
|
|
|
AddRepeatStep(@"increase hp with flash", delegate
|
|
|
|
|
{
|
|
|
|
|
healthProcessor.Health.Value += 0.1f;
|
|
|
|
|
healthProcessor.ApplyResult(new JudgementResult(new HitCircle(), new OsuJudgement())
|
|
|
|
|
{
|
|
|
|
|
Type = HitResult.Perfect
|
|
|
|
|
});
|
|
|
|
|
}, 3);
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-10-02 15:07:45 +08:00
|
|
|
|
}
|