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