1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-14 10:57:30 +08:00
osu-lazer/osu.Game.Rulesets.Osu/Tests/TestCaseSlider.cs

153 lines
5.9 KiB
C#
Raw Normal View History

2018-01-05 19:21:19 +08:00
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
2017-12-27 16:34:07 +08:00
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System;
using System.Collections.Generic;
2017-12-27 19:41:59 +08:00
using NUnit.Framework;
2017-12-27 16:34:07 +08:00
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Game.Audio;
using osu.Game.Beatmaps;
using osu.Game.Beatmaps.ControlPoints;
using osu.Game.Rulesets.Osu.Objects;
using osu.Game.Rulesets.Osu.Objects.Drawables;
using osu.Game.Tests.Visual;
using OpenTK;
using OpenTK.Graphics;
2018-01-01 18:55:24 +08:00
using osu.Game.Rulesets.Mods;
using System.Linq;
2018-01-03 00:04:00 +08:00
using osu.Game.Rulesets.Osu.Objects.Drawables.Pieces;
2017-12-27 16:34:07 +08:00
namespace osu.Game.Rulesets.Osu.Tests
{
2017-12-27 19:41:59 +08:00
[Ignore("getting CI working")]
2017-12-27 16:34:07 +08:00
public class TestCaseSlider : OsuTestCase
{
2017-12-30 00:44:38 +08:00
public override IReadOnlyList<Type> RequiredTypes => new[]
{
2018-01-03 00:04:00 +08:00
typeof(SliderBall),
typeof(SliderBody),
2017-12-30 00:44:38 +08:00
typeof(DrawableSlider),
2018-01-03 00:04:00 +08:00
typeof(DrawableRepeatPoint),
typeof(DrawableOsuHitObject)
2017-12-30 00:44:38 +08:00
};
2017-12-27 16:34:07 +08:00
private readonly Container content;
protected override Container<Drawable> Content => content;
private int depthIndex;
2018-01-01 18:55:24 +08:00
protected readonly List<Mod> Mods = new List<Mod>();
2017-12-27 16:34:07 +08:00
public TestCaseSlider()
{
base.Content.Add(content = new OsuInputManager(new RulesetInfo { ID = 0 }));
2018-01-01 18:55:24 +08:00
AddStep("Big Single", () => testSimpleBig());
AddStep("Medium Single", () => testSimpleMedium());
AddStep("Small Single", () => testSimpleSmall());
AddStep("Big 1 Repeat", () => testSimpleBig(1));
AddStep("Medium 1 Repeat", () => testSimpleMedium(1));
AddStep("Small 1 Repeat", () => testSimpleSmall(1));
AddStep("Big 2 Repeats", () => testSimpleBig(2));
AddStep("Medium 2 Repeats", () => testSimpleMedium(2));
AddStep("Small 2 Repeats", () => testSimpleSmall(2));
AddStep("Slow Slider", testSlowSpeed); // slow long sliders take ages already so no repeat steps
AddStep("Slow Short Slider", () => testShortSlowSpeed());
AddStep("Slow Short Slider 1 Repeats", () => testShortSlowSpeed(1));
AddStep("Slow Short Slider 2 Repeats", () => testShortSlowSpeed(2));
AddStep("Fast Slider", () => testHighSpeed());
AddStep("Fast Slider 1 Repeat", () => testHighSpeed(1));
AddStep("Fast Slider 2 Repeats", () => testHighSpeed(2));
AddStep("Fast Short Slider", () => testShortHighSpeed());
AddStep("Fast Short Slider 1 Repeat", () => testShortHighSpeed(1));
AddStep("Fast Short Slider 2 Repeats", () => testShortHighSpeed(2));
2018-01-01 18:55:24 +08:00
AddStep("Perfect Curve", testCurve);
// TODO more curve types?
2017-12-27 16:34:07 +08:00
}
2018-01-01 18:55:24 +08:00
private void testSimpleBig(int repeats = 0) => createSlider(2, repeats: repeats);
private void testSimpleMedium(int repeats = 0) => createSlider(5, repeats: repeats);
private void testSimpleSmall(int repeats = 0) => createSlider(7, repeats: repeats);
private void testSlowSpeed() => createSlider(speedMultiplier: 0.5);
private void testShortSlowSpeed(int repeats = 0) => createSlider(distance: 100, repeats: repeats, speedMultiplier: 0.5);
private void testHighSpeed(int repeats = 0) => createSlider(repeats: repeats, speedMultiplier: 15);
private void testShortHighSpeed(int repeats = 0) => createSlider(distance: 100, repeats: repeats, speedMultiplier: 15);
private void createSlider(float circleSize = 2, float distance = 400, int repeats = 0, double speedMultiplier = 2)
2017-12-27 16:34:07 +08:00
{
2018-01-01 18:55:24 +08:00
repeats++; // The first run through the slider is considered a repeat
var repeatSamples = new List<List<SampleInfo>>();
if (repeats > 1)
{
for (int i = 0; i < repeats; i++)
repeatSamples.Add(new List<SampleInfo>());
}
2017-12-27 16:34:07 +08:00
var slider = new Slider
{
2018-01-01 18:55:24 +08:00
StartTime = Time.Current + 1000,
Position = new Vector2(-(distance / 2), 0),
ComboColour = Color4.LightSeaGreen,
2017-12-27 16:34:07 +08:00
ControlPoints = new List<Vector2>
{
2018-01-01 18:55:24 +08:00
new Vector2(-(distance / 2), 0),
new Vector2(distance / 2, 0),
2017-12-27 16:34:07 +08:00
},
2018-01-01 18:55:24 +08:00
Distance = distance,
RepeatCount = repeats,
RepeatSamples = repeatSamples
2017-12-27 16:34:07 +08:00
};
2018-01-01 18:55:24 +08:00
addSlider(slider, circleSize, speedMultiplier);
2017-12-27 16:34:07 +08:00
}
2018-01-01 18:55:24 +08:00
private void testCurve()
2017-12-27 16:34:07 +08:00
{
var slider = new Slider
{
StartTime = Time.Current + 1000,
Position = new Vector2(-200, 0),
ComboColour = Color4.LightSeaGreen,
2017-12-27 16:34:07 +08:00
ControlPoints = new List<Vector2>
{
new Vector2(-200, 0),
2018-01-01 18:55:24 +08:00
new Vector2(0, 200),
new Vector2(200, 0)
2017-12-27 16:34:07 +08:00
},
2018-01-01 18:55:24 +08:00
Distance = 600
2017-12-27 16:34:07 +08:00
};
2018-01-01 18:55:24 +08:00
addSlider(slider, 2, 3);
}
2018-01-01 18:55:24 +08:00
private void addSlider(Slider slider, float circleSize, double speedMultiplier)
{
var cpi = new ControlPointInfo();
cpi.DifficultyPoints.Add(new DifficultyControlPoint { SpeedMultiplier = speedMultiplier });
2017-12-27 16:34:07 +08:00
2018-01-01 18:55:24 +08:00
slider.ApplyDefaults(cpi, new BeatmapDifficulty { CircleSize = circleSize });
var drawable = new DrawableSlider(slider)
{
Anchor = Anchor.Centre,
Depth = depthIndex++
};
2018-01-01 18:55:24 +08:00
foreach (var mod in Mods.OfType<IApplicableToDrawableHitObjects>())
mod.ApplyToDrawableHitObjects(new[] { drawable });
Add(drawable);
2017-12-27 16:34:07 +08:00
}
}
}