2019-01-24 17:43:03 +09: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 18:19:50 +09:00
|
|
|
|
|
2022-06-17 16:37:17 +09:00
|
|
|
|
#nullable disable
|
|
|
|
|
|
2020-02-17 16:37:24 +09:00
|
|
|
|
using System.Linq;
|
2018-04-13 18:19:50 +09:00
|
|
|
|
using NUnit.Framework;
|
|
|
|
|
using osu.Framework.Allocation;
|
2020-02-17 16:37:24 +09:00
|
|
|
|
using osu.Framework.Extensions.IEnumerableExtensions;
|
2018-04-13 18:19:50 +09:00
|
|
|
|
using osu.Framework.Graphics;
|
2020-02-21 18:09:50 +09:00
|
|
|
|
using osu.Framework.Testing;
|
2021-04-22 17:32:24 +09:00
|
|
|
|
using osu.Framework.Threading;
|
|
|
|
|
using osu.Framework.Utils;
|
2018-04-13 18:19:50 +09:00
|
|
|
|
using osu.Game.Beatmaps;
|
2020-03-10 15:26:39 +09:00
|
|
|
|
using osu.Game.Beatmaps.ControlPoints;
|
2020-07-16 15:25:07 +07:00
|
|
|
|
using osu.Game.Configuration;
|
2020-03-10 15:26:39 +09:00
|
|
|
|
using osu.Game.Rulesets.Catch.Judgements;
|
2020-02-21 18:09:50 +09:00
|
|
|
|
using osu.Game.Rulesets.Catch.Objects;
|
|
|
|
|
using osu.Game.Rulesets.Catch.Objects.Drawables;
|
2018-04-13 18:19:50 +09:00
|
|
|
|
using osu.Game.Rulesets.Catch.UI;
|
2020-03-10 15:26:39 +09:00
|
|
|
|
using osu.Game.Rulesets.Scoring;
|
2018-04-13 18:19:50 +09:00
|
|
|
|
|
|
|
|
|
namespace osu.Game.Rulesets.Catch.Tests
|
|
|
|
|
{
|
|
|
|
|
[TestFixture]
|
2022-11-24 14:32:20 +09:00
|
|
|
|
public partial class TestSceneCatcherArea : CatchSkinnableTestScene
|
2018-04-13 18:19:50 +09:00
|
|
|
|
{
|
|
|
|
|
private RulesetInfo catchRuleset;
|
2020-07-16 20:08:48 +02:00
|
|
|
|
|
|
|
|
|
[Resolved]
|
|
|
|
|
private OsuConfigManager config { get; set; }
|
2018-04-13 18:19:50 +09:00
|
|
|
|
|
2020-12-03 16:40:14 +09:00
|
|
|
|
private Catcher catcher => this.ChildrenOfType<Catcher>().First();
|
|
|
|
|
|
|
|
|
|
private float circleSize;
|
2020-07-16 20:12:32 +02:00
|
|
|
|
|
2021-04-22 17:32:24 +09:00
|
|
|
|
private ScheduledDelegate addManyFruit;
|
|
|
|
|
|
2021-10-01 14:56:42 +09:00
|
|
|
|
private IBeatmapDifficultyInfo beatmapDifficulty;
|
2021-04-22 17:32:24 +09:00
|
|
|
|
|
2019-05-14 22:37:25 +03:00
|
|
|
|
public TestSceneCatcherArea()
|
2018-04-13 18:19:50 +09:00
|
|
|
|
{
|
2020-12-03 16:40:14 +09:00
|
|
|
|
AddSliderStep<float>("circle size", 0, 8, 5, createCatcher);
|
|
|
|
|
AddToggleStep("hyper dash", t => this.ChildrenOfType<TestCatcherArea>().ForEach(area => area.ToggleHyperDash(t)));
|
2021-07-25 16:50:52 +02:00
|
|
|
|
AddToggleStep("toggle hit lighting", lighting => config.SetValue(OsuSetting.HitLighting, lighting));
|
2020-02-21 18:09:50 +09:00
|
|
|
|
|
2021-04-22 17:32:24 +09:00
|
|
|
|
AddStep("catch centered fruit", () => attemptCatch(new Fruit()));
|
|
|
|
|
AddStep("catch many random fruit", () =>
|
|
|
|
|
{
|
|
|
|
|
int count = 50;
|
|
|
|
|
|
|
|
|
|
addManyFruit?.Cancel();
|
|
|
|
|
addManyFruit = Scheduler.AddDelayed(() =>
|
|
|
|
|
{
|
|
|
|
|
attemptCatch(new Fruit
|
|
|
|
|
{
|
2021-04-22 17:47:03 +09:00
|
|
|
|
X = (RNG.NextSingle() - 0.5f) * Catcher.CalculateCatchWidth(beatmapDifficulty) * 0.6f,
|
2021-04-22 17:32:24 +09:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
if (count-- == 0)
|
|
|
|
|
addManyFruit?.Cancel();
|
|
|
|
|
}, 50, true);
|
|
|
|
|
});
|
2020-12-03 16:40:14 +09:00
|
|
|
|
AddStep("catch fruit last in combo", () => attemptCatch(new Fruit { LastInCombo = true }));
|
|
|
|
|
AddStep("catch kiai fruit", () => attemptCatch(new TestSceneCatcher.TestKiaiFruit()));
|
2020-12-14 13:18:14 +09:00
|
|
|
|
AddStep("miss last in combo", () => attemptCatch(new Fruit { X = 100, LastInCombo = true }));
|
2020-03-10 15:26:39 +09:00
|
|
|
|
}
|
|
|
|
|
|
2020-12-03 16:40:14 +09:00
|
|
|
|
private void attemptCatch(Fruit fruit)
|
2020-07-16 15:32:07 +07:00
|
|
|
|
{
|
2020-12-14 13:39:07 +09:00
|
|
|
|
fruit.X = fruit.OriginalX + catcher.X;
|
2021-04-22 17:32:24 +09:00
|
|
|
|
fruit.ApplyDefaults(new ControlPointInfo(), beatmapDifficulty);
|
2020-07-16 15:25:07 +07:00
|
|
|
|
|
2020-12-03 16:40:14 +09:00
|
|
|
|
foreach (var area in this.ChildrenOfType<CatcherArea>())
|
2020-03-10 15:26:39 +09:00
|
|
|
|
{
|
|
|
|
|
DrawableFruit drawable = new DrawableFruit(fruit);
|
|
|
|
|
area.Add(drawable);
|
|
|
|
|
|
|
|
|
|
Schedule(() =>
|
|
|
|
|
{
|
2020-12-08 17:04:26 +09:00
|
|
|
|
area.OnNewResult(drawable, new CatchJudgementResult(fruit, new CatchJudgement())
|
2020-12-03 16:40:14 +09:00
|
|
|
|
{
|
2021-07-21 16:28:31 +09:00
|
|
|
|
Type = area.Catcher.CanCatch(fruit) ? HitResult.Great : HitResult.Miss
|
2020-12-03 16:40:14 +09:00
|
|
|
|
});
|
2020-03-10 15:26:39 +09:00
|
|
|
|
|
|
|
|
|
drawable.Expire();
|
|
|
|
|
});
|
2020-12-03 16:40:14 +09:00
|
|
|
|
}
|
2018-04-13 18:19:50 +09:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void createCatcher(float size)
|
|
|
|
|
{
|
2020-12-03 16:40:14 +09:00
|
|
|
|
circleSize = size;
|
|
|
|
|
|
2021-04-22 17:32:24 +09:00
|
|
|
|
beatmapDifficulty = new BeatmapDifficulty
|
|
|
|
|
{
|
|
|
|
|
CircleSize = circleSize
|
|
|
|
|
};
|
|
|
|
|
|
2021-06-02 16:04:53 +09:00
|
|
|
|
SetContents(_ =>
|
2018-04-13 18:19:50 +09:00
|
|
|
|
{
|
2020-12-04 10:21:54 +09:00
|
|
|
|
return new CatchInputManager(catchRuleset)
|
2018-04-13 18:19:50 +09:00
|
|
|
|
{
|
2020-12-04 10:21:54 +09:00
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
2021-06-24 15:56:53 +09:00
|
|
|
|
new TestCatcherArea(beatmapDifficulty)
|
2020-12-04 10:21:54 +09:00
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
|
Origin = Anchor.TopCentre,
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
};
|
2020-02-17 16:37:24 +09:00
|
|
|
|
});
|
2018-04-13 18:19:50 +09:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
2020-07-16 20:08:48 +02:00
|
|
|
|
private void load(RulesetStore rulesets)
|
2018-04-13 18:19:50 +09:00
|
|
|
|
{
|
|
|
|
|
catchRuleset = rulesets.GetRuleset(2);
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-24 14:32:20 +09:00
|
|
|
|
private partial class TestCatcherArea : CatcherArea
|
2018-04-13 18:19:50 +09:00
|
|
|
|
{
|
2021-10-01 14:56:42 +09:00
|
|
|
|
public TestCatcherArea(IBeatmapDifficultyInfo beatmapDifficulty)
|
2018-04-13 18:19:50 +09:00
|
|
|
|
{
|
2021-07-26 17:46:56 +09:00
|
|
|
|
var droppedObjectContainer = new DroppedObjectContainer();
|
2021-07-19 20:11:49 +09:00
|
|
|
|
Add(droppedObjectContainer);
|
|
|
|
|
|
2021-07-27 18:59:55 +09:00
|
|
|
|
Catcher = new Catcher(droppedObjectContainer, beatmapDifficulty)
|
2021-07-19 19:44:40 +09:00
|
|
|
|
{
|
|
|
|
|
X = CatchPlayfield.CENTER_X
|
|
|
|
|
};
|
2018-04-13 18:19:50 +09:00
|
|
|
|
}
|
2018-06-03 15:31:51 +09:00
|
|
|
|
|
2021-07-21 16:28:31 +09:00
|
|
|
|
public void ToggleHyperDash(bool status) => Catcher.SetHyperDashState(status ? 2 : 1);
|
2018-04-13 18:19:50 +09:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|