2020-08-03 19:17:42 +00:00
|
|
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
|
|
|
// See the LICENCE file in the repository root for full licence text.
|
|
|
|
|
|
|
|
using System.Linq;
|
|
|
|
using NUnit.Framework;
|
2022-09-12 09:53:38 +00:00
|
|
|
using osu.Framework.Allocation;
|
2022-10-12 06:32:24 +00:00
|
|
|
using osu.Framework.Bindables;
|
2020-08-03 19:17:42 +00:00
|
|
|
using osu.Framework.Graphics;
|
2020-08-19 05:29:24 +00:00
|
|
|
using osu.Framework.Utils;
|
2020-08-03 19:17:42 +00:00
|
|
|
using osu.Game.Rulesets.Catch.Objects;
|
|
|
|
using osu.Game.Rulesets.Catch.Objects.Drawables;
|
|
|
|
using osu.Game.Rulesets.Catch.UI;
|
|
|
|
using osu.Game.Rulesets.Judgements;
|
|
|
|
using osu.Game.Rulesets.Scoring;
|
2022-10-12 06:32:24 +00:00
|
|
|
using osu.Game.Screens.Play;
|
|
|
|
using osu.Game.Tests.Visual;
|
2020-08-03 19:17:42 +00:00
|
|
|
using osuTK;
|
|
|
|
using osuTK.Graphics;
|
|
|
|
|
|
|
|
namespace osu.Game.Rulesets.Catch.Tests
|
|
|
|
{
|
|
|
|
public partial class TestSceneComboCounter : CatchSkinnableTestScene
|
|
|
|
{
|
2022-09-12 09:53:38 +00:00
|
|
|
private ScoreProcessor scoreProcessor = null!;
|
2020-08-03 19:17:42 +00:00
|
|
|
|
2020-08-19 05:29:24 +00:00
|
|
|
private Color4 judgedObjectColour = Color4.White;
|
|
|
|
|
2022-10-12 06:32:24 +00:00
|
|
|
private readonly Bindable<bool> showHud = new Bindable<bool>(true);
|
|
|
|
|
2022-09-12 09:53:38 +00:00
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
private void load()
|
|
|
|
{
|
2022-10-12 06:32:24 +00:00
|
|
|
Dependencies.CacheAs<Player>(new TestPlayer
|
|
|
|
{
|
|
|
|
ShowingOverlayComponents = { BindTarget = showHud },
|
|
|
|
});
|
2022-09-12 09:53:38 +00:00
|
|
|
}
|
|
|
|
|
2020-08-03 19:17:42 +00:00
|
|
|
[SetUp]
|
|
|
|
public void SetUp() => Schedule(() =>
|
|
|
|
{
|
2022-03-14 06:51:10 +00:00
|
|
|
scoreProcessor = new ScoreProcessor(new CatchRuleset());
|
2020-08-03 19:17:42 +00:00
|
|
|
|
2022-10-12 06:32:24 +00:00
|
|
|
showHud.Value = true;
|
2022-09-12 09:53:38 +00:00
|
|
|
|
2021-06-02 07:04:53 +00:00
|
|
|
SetContents(_ => new CatchComboDisplay
|
2020-08-03 19:17:42 +00:00
|
|
|
{
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
Scale = new Vector2(2.5f),
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void TestCatchComboCounter()
|
|
|
|
{
|
2020-09-29 08:16:55 +00:00
|
|
|
AddRepeatStep("perform hit", () => performJudgement(HitResult.Great), 20);
|
2020-08-03 19:17:42 +00:00
|
|
|
AddStep("perform miss", () => performJudgement(HitResult.Miss));
|
2020-08-19 05:29:24 +00:00
|
|
|
|
|
|
|
AddStep("randomize judged object colour", () =>
|
|
|
|
{
|
|
|
|
judgedObjectColour = new Color4(
|
|
|
|
RNG.NextSingle(1f),
|
|
|
|
RNG.NextSingle(1f),
|
|
|
|
RNG.NextSingle(1f),
|
|
|
|
1f
|
|
|
|
);
|
|
|
|
});
|
2022-09-12 09:53:38 +00:00
|
|
|
|
2022-10-12 06:32:24 +00:00
|
|
|
AddStep("set hud to never show", () => showHud.Value = false);
|
2022-09-12 09:53:38 +00:00
|
|
|
AddRepeatStep("perform hit", () => performJudgement(HitResult.Great), 5);
|
|
|
|
|
2022-10-12 06:32:24 +00:00
|
|
|
AddStep("set hud to show", () => showHud.Value = true);
|
2022-09-12 09:53:38 +00:00
|
|
|
AddRepeatStep("perform hit", () => performJudgement(HitResult.Great), 5);
|
2020-08-03 19:17:42 +00:00
|
|
|
}
|
|
|
|
|
2022-09-12 09:53:38 +00:00
|
|
|
private void performJudgement(HitResult type, Judgement? judgement = null)
|
2020-08-03 19:17:42 +00:00
|
|
|
{
|
2020-08-19 05:28:11 +00:00
|
|
|
var judgedObject = new DrawableFruit(new Fruit()) { AccentColour = { Value = judgedObjectColour } };
|
|
|
|
|
2020-08-03 19:17:42 +00:00
|
|
|
var result = new JudgementResult(judgedObject.HitObject, judgement ?? new Judgement()) { Type = type };
|
|
|
|
scoreProcessor.ApplyResult(result);
|
|
|
|
|
|
|
|
foreach (var counter in CreatedDrawables.Cast<CatchComboDisplay>())
|
|
|
|
counter.OnNewResult(judgedObject, result);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|