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
|
|
|
|
|
2022-06-17 07:37:17 +00:00
|
|
|
|
#nullable disable
|
|
|
|
|
|
2020-03-10 01:07:47 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Linq;
|
2017-12-01 11:31:54 +00:00
|
|
|
|
using NUnit.Framework;
|
2020-03-10 01:07:47 +00:00
|
|
|
|
using osu.Framework.Testing;
|
2017-12-01 06:08:12 +00:00
|
|
|
|
using osu.Game.Beatmaps;
|
2020-08-20 17:01:29 +00:00
|
|
|
|
using osu.Game.Beatmaps.ControlPoints;
|
2017-12-01 06:08:12 +00:00
|
|
|
|
using osu.Game.Rulesets.Catch.Objects;
|
2020-03-10 01:07:47 +00:00
|
|
|
|
using osu.Game.Rulesets.Catch.UI;
|
2020-03-10 08:49:51 +00:00
|
|
|
|
using osu.Game.Rulesets.Objects;
|
|
|
|
|
using osuTK;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2017-12-01 06:08:12 +00:00
|
|
|
|
namespace osu.Game.Rulesets.Catch.Tests
|
|
|
|
|
{
|
|
|
|
|
[TestFixture]
|
2020-04-17 07:32:12 +00:00
|
|
|
|
public class TestSceneHyperDash : TestSceneCatchPlayer
|
2017-12-01 06:08:12 +00:00
|
|
|
|
{
|
2019-09-13 10:29:49 +00:00
|
|
|
|
protected override bool Autoplay => true;
|
|
|
|
|
|
2020-08-24 02:38:03 +00:00
|
|
|
|
private int hyperDashCount;
|
|
|
|
|
private bool inHyperDash;
|
|
|
|
|
|
2019-06-27 10:19:22 +00:00
|
|
|
|
[Test]
|
|
|
|
|
public void TestHyperDash()
|
2019-03-18 07:39:34 +00:00
|
|
|
|
{
|
2020-08-23 14:11:56 +00:00
|
|
|
|
AddStep("reset count", () =>
|
|
|
|
|
{
|
|
|
|
|
inHyperDash = false;
|
|
|
|
|
hyperDashCount = 0;
|
2020-08-24 02:38:03 +00:00
|
|
|
|
|
|
|
|
|
// this needs to be done within the frame stable context due to how quickly hyperdash state changes occur.
|
2022-06-24 12:25:23 +00:00
|
|
|
|
Player.DrawableRuleset.FrameStableComponents.OnUpdate += _ =>
|
2020-08-24 02:38:03 +00:00
|
|
|
|
{
|
2021-07-21 07:27:44 +00:00
|
|
|
|
var catcher = Player.ChildrenOfType<Catcher>().FirstOrDefault();
|
2020-08-24 02:38:03 +00:00
|
|
|
|
|
|
|
|
|
if (catcher == null)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
if (catcher.HyperDashing != inHyperDash)
|
|
|
|
|
{
|
|
|
|
|
inHyperDash = catcher.HyperDashing;
|
|
|
|
|
if (catcher.HyperDashing)
|
|
|
|
|
hyperDashCount++;
|
|
|
|
|
}
|
|
|
|
|
};
|
2020-08-23 14:11:56 +00:00
|
|
|
|
});
|
2020-03-10 01:07:47 +00:00
|
|
|
|
|
2020-08-23 14:11:56 +00:00
|
|
|
|
AddAssert("First note is hyperdash", () => Beatmap.Value.Beatmap.HitObjects[0] is Fruit f && f.HyperDash);
|
2020-03-10 08:49:51 +00:00
|
|
|
|
|
2020-08-23 14:11:56 +00:00
|
|
|
|
for (int i = 0; i < 9; i++)
|
2020-03-10 01:07:47 +00:00
|
|
|
|
{
|
2020-08-23 14:11:56 +00:00
|
|
|
|
int count = i + 1;
|
2020-08-24 02:38:03 +00:00
|
|
|
|
AddUntilStep($"wait for hyperdash #{count}", () => hyperDashCount >= count);
|
2020-08-23 14:11:56 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2020-03-10 01:07:47 +00:00
|
|
|
|
|
2019-05-31 05:40:53 +00:00
|
|
|
|
protected override IBeatmap CreateBeatmap(RulesetInfo ruleset)
|
2017-12-01 06:08:12 +00:00
|
|
|
|
{
|
2019-03-02 13:05:56 +00:00
|
|
|
|
var beatmap = new Beatmap
|
|
|
|
|
{
|
|
|
|
|
BeatmapInfo =
|
|
|
|
|
{
|
2019-05-31 05:40:53 +00:00
|
|
|
|
Ruleset = ruleset,
|
2022-01-18 13:57:39 +00:00
|
|
|
|
Difficulty = new BeatmapDifficulty { CircleSize = 3.6f }
|
2019-03-02 13:05:56 +00:00
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
2020-08-20 17:01:29 +00:00
|
|
|
|
beatmap.ControlPointInfo.Add(0, new TimingControlPoint());
|
|
|
|
|
|
2020-03-10 01:07:47 +00:00
|
|
|
|
// Should produce a hyper-dash (edge case test)
|
2020-07-01 15:21:45 +00:00
|
|
|
|
beatmap.HitObjects.Add(new Fruit { StartTime = 1816, X = 56, NewCombo = true });
|
|
|
|
|
beatmap.HitObjects.Add(new Fruit { StartTime = 2008, X = 308, NewCombo = true });
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2020-03-10 01:07:47 +00:00
|
|
|
|
double startTime = 3000;
|
|
|
|
|
|
2020-07-01 15:21:45 +00:00
|
|
|
|
const float left_x = 0.02f * CatchPlayfield.WIDTH;
|
|
|
|
|
const float right_x = 0.98f * CatchPlayfield.WIDTH;
|
2020-03-10 01:07:47 +00:00
|
|
|
|
|
2020-03-10 08:49:51 +00:00
|
|
|
|
createObjects(() => new Fruit { X = left_x });
|
|
|
|
|
createObjects(() => new TestJuiceStream(right_x), 1);
|
|
|
|
|
createObjects(() => new TestJuiceStream(left_x), 1);
|
|
|
|
|
createObjects(() => new Fruit { X = right_x });
|
|
|
|
|
createObjects(() => new Fruit { X = left_x });
|
|
|
|
|
createObjects(() => new Fruit { X = right_x });
|
|
|
|
|
createObjects(() => new TestJuiceStream(left_x), 1);
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2020-08-21 03:30:33 +00:00
|
|
|
|
beatmap.ControlPointInfo.Add(startTime, new TimingControlPoint
|
2020-08-20 17:01:29 +00:00
|
|
|
|
{
|
|
|
|
|
BeatLength = 50
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
createObjects(() => new TestJuiceStream(left_x)
|
|
|
|
|
{
|
|
|
|
|
Path = new SliderPath(new[]
|
|
|
|
|
{
|
|
|
|
|
new PathControlPoint(Vector2.Zero),
|
|
|
|
|
new PathControlPoint(new Vector2(512, 0))
|
|
|
|
|
})
|
|
|
|
|
}, 1);
|
|
|
|
|
|
2017-12-01 06:08:12 +00:00
|
|
|
|
return beatmap;
|
2020-03-10 01:07:47 +00:00
|
|
|
|
|
2020-03-10 08:49:51 +00:00
|
|
|
|
void createObjects(Func<CatchHitObject> createObject, int count = 3)
|
2020-03-10 01:07:47 +00:00
|
|
|
|
{
|
|
|
|
|
const float spacing = 140;
|
|
|
|
|
|
2020-03-10 08:49:51 +00:00
|
|
|
|
for (int i = 0; i < count; i++)
|
2020-03-10 01:07:47 +00:00
|
|
|
|
{
|
|
|
|
|
var hitObject = createObject();
|
|
|
|
|
hitObject.StartTime = startTime + i * spacing;
|
|
|
|
|
beatmap.HitObjects.Add(hitObject);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
startTime += 700;
|
|
|
|
|
}
|
2017-12-01 06:08:12 +00:00
|
|
|
|
}
|
2020-03-10 08:49:51 +00:00
|
|
|
|
|
|
|
|
|
private class TestJuiceStream : JuiceStream
|
|
|
|
|
{
|
|
|
|
|
public TestJuiceStream(float x)
|
|
|
|
|
{
|
|
|
|
|
X = x;
|
2020-03-11 03:56:12 +00:00
|
|
|
|
|
2020-03-10 08:49:51 +00:00
|
|
|
|
Path = new SliderPath(new[]
|
|
|
|
|
{
|
2020-03-11 03:56:12 +00:00
|
|
|
|
new PathControlPoint(Vector2.Zero),
|
|
|
|
|
new PathControlPoint(new Vector2(30, 0)),
|
2020-03-10 08:49:51 +00:00
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
2017-12-01 06:08:12 +00:00
|
|
|
|
}
|
|
|
|
|
}
|