1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-09 09:37:42 +08:00
osu-lazer/osu.Desktop.VisualTests/Tests/TestCaseTaikoPlayfield.cs

149 lines
4.4 KiB
C#
Raw Normal View History

2017-03-21 14:09:54 +08:00
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
2017-03-28 10:18:12 +08:00
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Primitives;
2017-03-21 14:54:57 +08:00
using osu.Framework.MathUtils;
2017-03-28 20:03:34 +08:00
using osu.Framework.Testing;
2017-03-21 20:27:20 +08:00
using osu.Framework.Timing;
2017-03-21 14:54:57 +08:00
using osu.Game.Modes.Objects.Drawables;
using osu.Game.Modes.Taiko.Judgements;
using osu.Game.Modes.Taiko.Objects;
2017-03-21 19:39:18 +08:00
using osu.Game.Modes.Taiko.Objects.Drawable;
2017-03-21 14:09:54 +08:00
using osu.Game.Modes.Taiko.UI;
namespace osu.Desktop.VisualTests.Tests
{
internal class TestCaseTaikoPlayfield : TestCase
{
public override string Description => "Taiko playfield";
2017-03-21 14:54:57 +08:00
private TaikoPlayfield playfield;
2017-03-21 20:27:20 +08:00
public TestCaseTaikoPlayfield()
{
Clock = new FramedClock();
}
2017-03-21 14:09:54 +08:00
public override void Reset()
{
base.Reset();
2017-03-31 16:55:07 +08:00
AddStep("Hit!", addHitJudgement);
AddStep("Miss :(", addMissJudgement);
AddStep("Swell", addSwell);
AddStep("Centre", () => addCentreHit(false));
AddStep("Strong Centre", () => addCentreHit(true));
AddStep("Rim", () => addRimHit(false));
AddStep("Strong Rim", () => addRimHit(true));
2017-04-01 22:59:44 +08:00
AddStep("Add bar line", addBarLine);
2017-03-21 14:54:57 +08:00
2017-03-28 10:18:12 +08:00
Add(new Container
2017-03-21 14:09:54 +08:00
{
2017-03-28 10:18:12 +08:00
RelativeSizeAxes = Axes.X,
Y = 200,
Padding = new MarginPadding { Left = 200 },
Children = new[]
{
playfield = new TaikoPlayfield()
}
2017-03-21 14:09:54 +08:00
});
}
2017-03-21 14:54:57 +08:00
private void addHitJudgement()
{
2017-03-22 00:42:40 +08:00
TaikoHitResult hitResult = RNG.Next(2) == 0 ? TaikoHitResult.Good : TaikoHitResult.Great;
2017-03-21 14:54:57 +08:00
2017-03-23 15:56:42 +08:00
playfield.OnJudgement(new DrawableTestHit(new Hit())
2017-03-21 14:54:57 +08:00
{
2017-03-22 00:42:40 +08:00
X = RNG.NextSingle(hitResult == TaikoHitResult.Good ? -0.1f : -0.05f, hitResult == TaikoHitResult.Good ? 0.1f : 0.05f),
Judgement = new TaikoJudgement
2017-03-21 14:54:57 +08:00
{
Result = HitResult.Hit,
2017-03-22 00:42:40 +08:00
TaikoResult = hitResult,
2017-03-21 14:54:57 +08:00
TimeOffset = 0,
SecondHit = RNG.Next(10) == 0
2017-03-21 14:54:57 +08:00
}
});
}
private void addMissJudgement()
{
2017-03-23 15:56:42 +08:00
playfield.OnJudgement(new DrawableTestHit(new Hit())
2017-03-21 14:54:57 +08:00
{
Judgement = new TaikoJudgement
2017-03-21 14:54:57 +08:00
{
Result = HitResult.Miss,
TimeOffset = 0
2017-03-21 14:54:57 +08:00
}
});
}
2017-03-21 20:27:20 +08:00
private void addBarLine()
{
bool isMajor = RNG.Next(8) == 0;
BarLine bl = new BarLine
{
StartTime = Time.Current + 1000,
PreEmpt = 1000
};
playfield.AddBarLine(isMajor ? new DrawableMajorBarLine(bl) : new DrawableBarLine(bl));
}
2017-03-28 14:05:45 +08:00
private void addSwell()
{
playfield.Add(new DrawableSwell(new Swell
{
StartTime = Time.Current + 1000,
EndTime = Time.Current + 5000,
PreEmpt = 1000
}));
}
2017-03-28 10:18:12 +08:00
private void addCentreHit(bool strong)
{
Hit h = new Hit
{
StartTime = Time.Current + 1000,
PreEmpt = 1000
};
if (strong)
playfield.Add(new DrawableStrongCentreHit(h));
else
playfield.Add(new DrawableCentreHit(h));
}
private void addRimHit(bool strong)
{
Hit h = new Hit
{
StartTime = Time.Current + 1000,
PreEmpt = 1000
};
if (strong)
playfield.Add(new DrawableStrongRimHit(h));
else
playfield.Add(new DrawableRimHit(h));
}
private class DrawableTestHit : DrawableHitObject<TaikoHitObject, TaikoJudgement>
2017-03-21 14:54:57 +08:00
{
public DrawableTestHit(TaikoHitObject hitObject)
: base(hitObject)
{
}
protected override TaikoJudgement CreateJudgement() => new TaikoJudgement();
2017-03-21 14:54:57 +08:00
protected override void UpdateState(ArmedState state)
{
}
}
2017-03-21 14:09:54 +08:00
}
}