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.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);
|
|
|
|
|
|
2024-01-11 17:17:32 +08:00
|
|
|
|
protected override Drawable CreateArgonImplementation() => new ArgonHealthDisplay { Scale = new Vector2(0.6f), Width = 600, UseRelativeSize = { Value = false } };
|
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
|
|
|
|
|
2024-03-05 08:01:46 +08:00
|
|
|
|
public override void SetUpSteps()
|
2021-06-01 14:57:43 +08:00
|
|
|
|
{
|
|
|
|
|
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
|
|
|
|
});
|
2024-03-05 08:01:46 +08:00
|
|
|
|
|
|
|
|
|
base.SetUpSteps();
|
2021-06-01 14:57:43 +08:00
|
|
|
|
}
|
|
|
|
|
|
2024-01-09 16:09:19 +08:00
|
|
|
|
protected override void Update()
|
|
|
|
|
{
|
|
|
|
|
base.Update();
|
|
|
|
|
|
|
|
|
|
healthProcessor.Health.Value -= 0.0001f * Time.Elapsed;
|
|
|
|
|
}
|
|
|
|
|
|
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
|
|
|
|
}
|