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-12-04 09:21:54 +08:00
|
|
|
|
using osu.Framework.Graphics.Containers;
|
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;
|
2020-07-16 16:25:07 +08:00
|
|
|
|
using osu.Game.Configuration;
|
2020-03-10 14:26:39 +08:00
|
|
|
|
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.Scoring;
|
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;
|
2020-07-17 02:08:48 +08:00
|
|
|
|
|
|
|
|
|
[Resolved]
|
|
|
|
|
private OsuConfigManager config { get; set; }
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2020-12-03 15:40:14 +08:00
|
|
|
|
private Catcher catcher => this.ChildrenOfType<Catcher>().First();
|
|
|
|
|
|
|
|
|
|
private float circleSize;
|
2020-07-17 02:12:32 +08:00
|
|
|
|
|
2019-05-15 03:37:25 +08:00
|
|
|
|
public TestSceneCatcherArea()
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
2020-12-03 15:40:14 +08:00
|
|
|
|
AddSliderStep<float>("circle size", 0, 8, 5, createCatcher);
|
|
|
|
|
AddToggleStep("hyper dash", t => this.ChildrenOfType<TestCatcherArea>().ForEach(area => area.ToggleHyperDash(t)));
|
2020-02-21 17:09:50 +08:00
|
|
|
|
|
2020-12-03 15:40:14 +08:00
|
|
|
|
AddStep("catch fruit", () => attemptCatch(new Fruit()));
|
|
|
|
|
AddStep("catch fruit last in combo", () => attemptCatch(new Fruit { LastInCombo = true }));
|
|
|
|
|
AddStep("catch kiai fruit", () => attemptCatch(new TestSceneCatcher.TestKiaiFruit()));
|
2020-12-14 12:18:14 +08:00
|
|
|
|
AddStep("miss last in combo", () => attemptCatch(new Fruit { X = 100, LastInCombo = true }));
|
2020-03-10 14:26:39 +08:00
|
|
|
|
}
|
|
|
|
|
|
2020-12-03 15:40:14 +08:00
|
|
|
|
private void attemptCatch(Fruit fruit)
|
2020-07-16 16:32:07 +08:00
|
|
|
|
{
|
2020-12-14 12:39:07 +08:00
|
|
|
|
fruit.X = fruit.OriginalX + catcher.X;
|
2020-12-03 15:40:14 +08:00
|
|
|
|
fruit.ApplyDefaults(new ControlPointInfo(), new BeatmapDifficulty
|
2020-07-16 16:25:07 +08:00
|
|
|
|
{
|
2020-12-03 15:40:14 +08:00
|
|
|
|
CircleSize = circleSize
|
|
|
|
|
});
|
2020-07-16 16:25:07 +08:00
|
|
|
|
|
2020-12-03 15:40:14 +08:00
|
|
|
|
foreach (var area in this.ChildrenOfType<CatcherArea>())
|
2020-03-10 14:26:39 +08:00
|
|
|
|
{
|
|
|
|
|
DrawableFruit drawable = new DrawableFruit(fruit);
|
|
|
|
|
area.Add(drawable);
|
|
|
|
|
|
|
|
|
|
Schedule(() =>
|
|
|
|
|
{
|
2020-12-08 16:04:26 +08:00
|
|
|
|
area.OnNewResult(drawable, new CatchJudgementResult(fruit, new CatchJudgement())
|
2020-12-03 15:40:14 +08:00
|
|
|
|
{
|
2020-12-08 13:28:30 +08:00
|
|
|
|
Type = area.MovableCatcher.CanCatch(fruit) ? HitResult.Great : HitResult.Miss
|
2020-12-03 15:40:14 +08:00
|
|
|
|
});
|
2020-03-10 14:26:39 +08:00
|
|
|
|
|
|
|
|
|
drawable.Expire();
|
|
|
|
|
});
|
2020-12-03 15:40:14 +08:00
|
|
|
|
}
|
2018-04-13 17:19:50 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void createCatcher(float size)
|
|
|
|
|
{
|
2020-12-03 15:40:14 +08:00
|
|
|
|
circleSize = size;
|
|
|
|
|
|
2020-12-04 09:21:54 +08:00
|
|
|
|
SetContents(() =>
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
2020-12-09 09:35:01 +08:00
|
|
|
|
var droppedObjectContainer = new Container<CaughtObject>
|
2020-12-08 21:38:10 +08:00
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both
|
|
|
|
|
};
|
2020-12-04 09:21:54 +08:00
|
|
|
|
|
|
|
|
|
return new CatchInputManager(catchRuleset)
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
2020-12-04 09:21:54 +08:00
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
|
|
|
|
droppedObjectContainer,
|
|
|
|
|
new TestCatcherArea(droppedObjectContainer, new BeatmapDifficulty { CircleSize = size })
|
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
|
Origin = Anchor.TopCentre,
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
};
|
2020-02-17 15:37:24 +08:00
|
|
|
|
});
|
2018-04-13 17:19:50 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
2020-07-17 02:08:48 +08:00
|
|
|
|
private void load(RulesetStore rulesets)
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
|
|
|
|
catchRuleset = rulesets.GetRuleset(2);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private class TestCatcherArea : CatcherArea
|
|
|
|
|
{
|
2020-12-09 09:35:01 +08:00
|
|
|
|
public TestCatcherArea(Container<CaughtObject> droppedObjectContainer, BeatmapDifficulty beatmapDifficulty)
|
2020-12-04 09:21:54 +08:00
|
|
|
|
: base(droppedObjectContainer, beatmapDifficulty)
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
|
|
|
|
}
|
2018-06-03 14:31:51 +08:00
|
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|