1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-22 16:47:24 +08:00
osu-lazer/osu.Game.Rulesets.Mania/Tests/TestCaseManiaPlayfield.cs

190 lines
6.8 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-09-18 21:32:49 +08:00
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System;
2018-01-03 21:58:08 +08:00
using System.Collections.Generic;
2017-09-18 21:32:49 +08:00
using System.Linq;
using NUnit.Framework;
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Timing;
2018-01-03 21:58:08 +08:00
using osu.Game.Rulesets.Mania.Beatmaps;
2017-09-18 21:32:49 +08:00
using osu.Game.Rulesets.Mania.Judgements;
using osu.Game.Rulesets.Mania.Objects;
using osu.Game.Rulesets.Mania.Objects.Drawables;
using osu.Game.Rulesets.Mania.UI;
using osu.Game.Rulesets.Scoring;
2017-09-18 21:32:49 +08:00
using osu.Game.Tests.Visual;
2017-10-10 15:39:23 +08:00
namespace osu.Game.Rulesets.Mania.Tests
2017-09-18 21:32:49 +08:00
{
[TestFixture]
2017-10-23 19:58:50 +08:00
[Ignore("getting CI working")]
2017-12-20 20:47:45 +08:00
public class TestCaseManiaPlayfield : OsuTestCase
2017-09-18 21:32:49 +08:00
{
private const double start_time = 500;
private const double duration = 500;
protected override double TimePerAction => 200;
private RulesetInfo maniaRuleset;
public TestCaseManiaPlayfield()
{
var rng = new Random(1337);
AddStep("1 column", () => createPlayfield(1, SpecialColumnPosition.Normal));
AddStep("4 columns", () => createPlayfield(4, SpecialColumnPosition.Normal));
AddStep("Left special style", () => createPlayfield(4, SpecialColumnPosition.Left));
AddStep("Right special style", () => createPlayfield(4, SpecialColumnPosition.Right));
AddStep("5 columns", () => createPlayfield(5, SpecialColumnPosition.Normal));
AddStep("8 columns", () => createPlayfield(8, SpecialColumnPosition.Normal));
2018-01-03 22:50:52 +08:00
AddStep("4 + 4 columns", () =>
{
2018-01-06 10:08:04 +08:00
var stages = new List<StageDefinition>
{
2018-01-06 10:08:04 +08:00
new StageDefinition { Columns = 4 },
new StageDefinition { Columns = 4 },
};
createPlayfield(stages, SpecialColumnPosition.Normal);
});
2018-01-15 14:52:07 +08:00
AddStep("2 + 4 + 2 columns", () =>
{
2018-01-06 10:08:04 +08:00
var stages = new List<StageDefinition>
{
2018-01-06 10:08:04 +08:00
new StageDefinition { Columns = 2 },
new StageDefinition { Columns = 4 },
new StageDefinition { Columns = 2 },
};
createPlayfield(stages, SpecialColumnPosition.Normal);
});
2018-01-15 14:52:07 +08:00
AddStep("1 + 8 + 1 columns", () =>
{
2018-01-06 10:08:04 +08:00
var stages = new List<StageDefinition>
{
2018-01-06 10:08:04 +08:00
new StageDefinition { Columns = 1 },
new StageDefinition { Columns = 8 },
new StageDefinition { Columns = 1 },
};
createPlayfield(stages, SpecialColumnPosition.Normal);
});
2017-09-18 21:32:49 +08:00
AddStep("Left special style", () => createPlayfield(8, SpecialColumnPosition.Left));
AddStep("Right special style", () => createPlayfield(8, SpecialColumnPosition.Right));
AddStep("Reversed", () => createPlayfield(4, SpecialColumnPosition.Normal, true));
AddStep("Notes with input", () => createPlayfieldWithNotes());
AddStep("Notes with input (reversed)", () => createPlayfieldWithNotes(true));
AddStep("Notes with gravity", () => createPlayfieldWithNotes());
AddStep("Notes with gravity (reversed)", () => createPlayfieldWithNotes(true));
2017-09-18 21:32:49 +08:00
AddStep("Hit explosion", () =>
{
var playfield = createPlayfield(4, SpecialColumnPosition.Normal);
int col = rng.Next(0, 4);
var note = new DrawableNote(new Note { Column = col }, ManiaAction.Key1)
{
AccentColour = playfield.Columns.ElementAt(col).AccentColour
};
playfield.OnJudgement(note, new ManiaJudgement { Result = HitResult.Perfect });
});
}
[BackgroundDependencyLoader]
private void load(RulesetStore rulesets)
{
maniaRuleset = rulesets.GetRuleset(3);
}
private ManiaPlayfield createPlayfield(int cols, SpecialColumnPosition specialPos, bool inverted = false)
{
2018-01-06 10:08:04 +08:00
var stages = new List<StageDefinition>
{
2018-01-06 10:08:04 +08:00
new StageDefinition { Columns = cols },
};
2018-01-15 14:52:07 +08:00
return createPlayfield(stages, specialPos, inverted);
}
private ManiaPlayfield createPlayfield(List<StageDefinition> stages, SpecialColumnPosition specialPos, bool inverted = false)
2017-09-18 21:32:49 +08:00
{
Clear();
var inputManager = new ManiaInputManager(maniaRuleset, stages.Sum(g => g.Columns)) { RelativeSizeAxes = Axes.Both };
2017-09-18 21:32:49 +08:00
Add(inputManager);
ManiaPlayfield playfield;
2018-01-03 21:58:08 +08:00
inputManager.Add(playfield = new ManiaPlayfield(stages)
2017-09-18 21:32:49 +08:00
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
});
playfield.SpecialColumnPosition.Value = specialPos;
2017-09-18 21:32:49 +08:00
playfield.Inverted.Value = inverted;
return playfield;
}
private void createPlayfieldWithNotes(bool inverted = false)
2017-09-18 21:32:49 +08:00
{
Clear();
var rateAdjustClock = new StopwatchClock(true) { Rate = 1 };
var inputManager = new ManiaInputManager(maniaRuleset, 4) { RelativeSizeAxes = Axes.Both };
Add(inputManager);
ManiaPlayfield playfield;
2018-01-06 10:08:04 +08:00
var stages = new List<StageDefinition>
2018-01-03 21:58:08 +08:00
{
2018-01-06 10:08:04 +08:00
new StageDefinition { Columns = 4 },
2018-01-03 21:58:08 +08:00
};
2018-01-15 14:52:07 +08:00
2018-01-03 21:58:08 +08:00
inputManager.Add(playfield = new ManiaPlayfield(stages)
2017-09-18 21:32:49 +08:00
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Clock = new FramedClock(rateAdjustClock)
});
playfield.Inverted.Value = inverted;
for (double t = start_time; t <= start_time + duration; t += 100)
{
playfield.Add(new DrawableNote(new Note
{
StartTime = t,
Column = 0
}, ManiaAction.Key1));
playfield.Add(new DrawableNote(new Note
{
StartTime = t,
Column = 3
}, ManiaAction.Key4));
}
playfield.Add(new DrawableHoldNote(new HoldNote
{
StartTime = start_time,
Duration = duration,
Column = 1
}, ManiaAction.Key2));
playfield.Add(new DrawableHoldNote(new HoldNote
{
StartTime = start_time,
Duration = duration,
Column = 2
}, ManiaAction.Key3));
}
}
}