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;
|
|
|
|
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;
|
|
|
|
using osuTK;
|
|
|
|
using osuTK.Graphics;
|
|
|
|
|
|
|
|
namespace osu.Game.Rulesets.Catch.Tests
|
|
|
|
{
|
|
|
|
public class TestSceneComboCounter : CatchSkinnableTestScene
|
|
|
|
{
|
|
|
|
private ScoreProcessor scoreProcessor;
|
|
|
|
|
2020-08-19 05:29:24 +00:00
|
|
|
private Color4 judgedObjectColour = Color4.White;
|
|
|
|
|
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
|
|
|
|
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
|
|
|
|
);
|
|
|
|
});
|
2020-08-03 19:17:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
private void performJudgement(HitResult type, Judgement judgement = null)
|
|
|
|
{
|
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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|