2019-01-24 16:43:03 +08: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.
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2020-02-17 15:37:24 +08:00
|
|
|
|
using System.Linq;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
using NUnit.Framework;
|
|
|
|
|
using osu.Framework.Allocation;
|
2020-02-17 15:37:24 +08:00
|
|
|
|
using osu.Framework.Extensions.IEnumerableExtensions;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
using osu.Framework.Graphics;
|
2020-02-21 17:09:50 +08:00
|
|
|
|
using osu.Framework.Testing;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
using osu.Game.Beatmaps;
|
2020-03-10 14:26:39 +08:00
|
|
|
|
using osu.Game.Beatmaps.ControlPoints;
|
|
|
|
|
using osu.Game.Rulesets.Catch.Beatmaps;
|
|
|
|
|
using osu.Game.Rulesets.Catch.Judgements;
|
2020-02-21 17:09:50 +08:00
|
|
|
|
using osu.Game.Rulesets.Catch.Objects;
|
|
|
|
|
using osu.Game.Rulesets.Catch.Objects.Drawables;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
using osu.Game.Rulesets.Catch.UI;
|
2020-03-10 14:26:39 +08:00
|
|
|
|
using osu.Game.Rulesets.Judgements;
|
|
|
|
|
using osu.Game.Rulesets.Scoring;
|
|
|
|
|
using osu.Game.Rulesets.UI;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
|
|
|
|
namespace osu.Game.Rulesets.Catch.Tests
|
|
|
|
|
{
|
|
|
|
|
[TestFixture]
|
2020-04-07 14:38:29 +08:00
|
|
|
|
public class TestSceneCatcherArea : CatchSkinnableTestScene
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
|
|
|
|
private RulesetInfo catchRuleset;
|
|
|
|
|
|
2019-05-15 03:37:25 +08:00
|
|
|
|
public TestSceneCatcherArea()
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
|
|
|
|
AddSliderStep<float>("CircleSize", 0, 8, 5, createCatcher);
|
2020-02-17 15:37:24 +08:00
|
|
|
|
AddToggleStep("Hyperdash", t =>
|
|
|
|
|
CreatedDrawables.OfType<CatchInputManager>().Select(i => i.Child)
|
|
|
|
|
.OfType<TestCatcherArea>().ForEach(c => c.ToggleHyperDash(t)));
|
2020-02-21 17:09:50 +08:00
|
|
|
|
|
2020-03-10 14:26:39 +08:00
|
|
|
|
AddRepeatStep("catch fruit", () => catchFruit(new TestFruit(false)
|
|
|
|
|
{
|
|
|
|
|
X = this.ChildrenOfType<CatcherArea>().First().MovableCatcher.X
|
|
|
|
|
}), 20);
|
|
|
|
|
AddRepeatStep("catch fruit last in combo", () => catchFruit(new TestFruit(false)
|
|
|
|
|
{
|
|
|
|
|
X = this.ChildrenOfType<CatcherArea>().First().MovableCatcher.X,
|
|
|
|
|
LastInCombo = true,
|
|
|
|
|
}), 20);
|
|
|
|
|
AddRepeatStep("catch kiai fruit", () => catchFruit(new TestFruit(true)
|
|
|
|
|
{
|
|
|
|
|
X = this.ChildrenOfType<CatcherArea>().First().MovableCatcher.X,
|
|
|
|
|
}), 20);
|
|
|
|
|
AddRepeatStep("miss fruit", () => catchFruit(new Fruit
|
|
|
|
|
{
|
|
|
|
|
X = this.ChildrenOfType<CatcherArea>().First().MovableCatcher.X + 100,
|
|
|
|
|
LastInCombo = true,
|
|
|
|
|
}, true), 20);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void catchFruit(Fruit fruit, bool miss = false)
|
|
|
|
|
{
|
|
|
|
|
this.ChildrenOfType<CatcherArea>().ForEach(area =>
|
|
|
|
|
{
|
|
|
|
|
DrawableFruit drawable = new DrawableFruit(fruit);
|
|
|
|
|
area.Add(drawable);
|
|
|
|
|
|
|
|
|
|
Schedule(() =>
|
|
|
|
|
{
|
|
|
|
|
area.AttemptCatch(fruit);
|
|
|
|
|
area.OnResult(drawable, new JudgementResult(fruit, new CatchJudgement()) { Type = miss ? HitResult.Miss : HitResult.Great });
|
|
|
|
|
|
|
|
|
|
drawable.Expire();
|
|
|
|
|
});
|
|
|
|
|
});
|
2018-04-13 17:19:50 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void createCatcher(float size)
|
|
|
|
|
{
|
2020-02-17 15:37:24 +08:00
|
|
|
|
SetContents(() => new CatchInputManager(catchRuleset)
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
2020-02-17 15:37:24 +08:00
|
|
|
|
Child = new TestCatcherArea(new BeatmapDifficulty { CircleSize = size })
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
2020-07-01 23:21:45 +08:00
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
|
Origin = Anchor.TopCentre,
|
2020-03-10 14:26:39 +08:00
|
|
|
|
CreateDrawableRepresentation = ((DrawableRuleset<CatchHitObject>)catchRuleset.CreateInstance().CreateDrawableRulesetWith(new CatchBeatmap())).CreateDrawableRepresentation
|
2018-04-13 17:19:50 +08:00
|
|
|
|
},
|
2020-02-17 15:37:24 +08:00
|
|
|
|
});
|
2018-04-13 17:19:50 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
|
private void load(RulesetStore rulesets)
|
|
|
|
|
{
|
|
|
|
|
catchRuleset = rulesets.GetRuleset(2);
|
|
|
|
|
}
|
|
|
|
|
|
2020-03-10 14:26:39 +08:00
|
|
|
|
public class TestFruit : Fruit
|
|
|
|
|
{
|
|
|
|
|
public TestFruit(bool kiai)
|
|
|
|
|
{
|
|
|
|
|
var kiaiCpi = new ControlPointInfo();
|
|
|
|
|
kiaiCpi.Add(0, new EffectControlPoint { KiaiMode = kiai });
|
|
|
|
|
|
|
|
|
|
ApplyDefaultsToSelf(kiaiCpi, new BeatmapDifficulty());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-04-13 17:19:50 +08:00
|
|
|
|
private class TestCatcherArea : CatcherArea
|
|
|
|
|
{
|
|
|
|
|
public TestCatcherArea(BeatmapDifficulty beatmapDifficulty)
|
|
|
|
|
: base(beatmapDifficulty)
|
|
|
|
|
{
|
|
|
|
|
}
|
2018-06-03 14:31:51 +08:00
|
|
|
|
|
2020-02-21 17:09:50 +08:00
|
|
|
|
public new Catcher MovableCatcher => base.MovableCatcher;
|
|
|
|
|
|
2018-07-05 10:32:09 +08:00
|
|
|
|
public void ToggleHyperDash(bool status) => MovableCatcher.SetHyperDashState(status ? 2 : 1);
|
2018-04-13 17:19:50 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|