1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-18 17:32:55 +08:00
osu-lazer/osu.Game.Rulesets.Osu.Tests/TestSceneSpinner.cs

67 lines
2.2 KiB
C#
Raw Normal View History

// 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
using System.Linq;
using NUnit.Framework;
using osu.Framework.Graphics;
using osu.Game.Beatmaps;
using osu.Game.Beatmaps.ControlPoints;
using osu.Game.Rulesets.Mods;
using osu.Game.Rulesets.Osu.Objects;
using osu.Game.Rulesets.Osu.Objects.Drawables;
namespace osu.Game.Rulesets.Osu.Tests
{
[TestFixture]
public class TestSceneSpinner : OsuSkinnableTestScene
2018-04-13 17:19:50 +08:00
{
private int depthIndex;
public TestSceneSpinner()
2018-04-13 17:19:50 +08:00
{
AddStep("Miss Big", () => SetContents(() => testSingle(2)));
AddStep("Miss Medium", () => SetContents(() => testSingle(5)));
AddStep("Miss Small", () => SetContents(() => testSingle(7)));
AddStep("Hit Big", () => SetContents(() => testSingle(2, true)));
AddStep("Hit Medium", () => SetContents(() => testSingle(5, true)));
AddStep("Hit Small", () => SetContents(() => testSingle(7, true)));
2018-04-13 17:19:50 +08:00
}
private Drawable testSingle(float circleSize, bool auto = false)
2018-04-13 17:19:50 +08:00
{
2020-07-20 14:19:17 +08:00
var spinner = new Spinner { StartTime = Time.Current + 2000, EndTime = Time.Current + 5000 };
2018-04-13 17:19:50 +08:00
spinner.ApplyDefaults(new ControlPointInfo(), new BeatmapDifficulty { CircleSize = circleSize });
var drawable = new TestDrawableSpinner(spinner, auto)
{
Anchor = Anchor.Centre,
Depth = depthIndex++
};
2019-12-13 20:45:38 +08:00
foreach (var mod in SelectedMods.Value.OfType<IApplicableToDrawableHitObjects>())
2018-04-13 17:19:50 +08:00
mod.ApplyToDrawableHitObjects(new[] { drawable });
return drawable;
2018-04-13 17:19:50 +08:00
}
private class TestDrawableSpinner : DrawableSpinner
{
private readonly bool auto;
2018-04-13 17:19:50 +08:00
2019-02-28 12:31:40 +08:00
public TestDrawableSpinner(Spinner s, bool auto)
: base(s)
2018-04-13 17:19:50 +08:00
{
this.auto = auto;
}
protected override void Update()
2018-04-13 17:19:50 +08:00
{
base.Update();
if (auto)
RotationTracker.AddRotation((float)(Clock.ElapsedFrameTime * 3));
2018-04-13 17:19:50 +08:00
}
}
}
}