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
|
|
|
|
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using NUnit.Framework;
|
|
|
|
|
using osu.Framework.Allocation;
|
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
|
using osu.Framework.MathUtils;
|
|
|
|
|
using osu.Game.Beatmaps;
|
|
|
|
|
using osu.Game.Beatmaps.ControlPoints;
|
2018-08-02 11:36:08 +00:00
|
|
|
|
using osu.Game.Rulesets.Judgements;
|
2019-04-08 09:32:05 +00:00
|
|
|
|
using osu.Game.Rulesets.Mods;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
using osu.Game.Rulesets.Objects;
|
|
|
|
|
using osu.Game.Rulesets.Objects.Drawables;
|
2019-09-06 06:24:00 +00:00
|
|
|
|
using osu.Game.Rulesets.Scoring;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
using osu.Game.Rulesets.Taiko.Judgements;
|
|
|
|
|
using osu.Game.Rulesets.Taiko.Objects;
|
|
|
|
|
using osu.Game.Rulesets.Taiko.Objects.Drawables;
|
|
|
|
|
using osu.Game.Rulesets.Taiko.UI;
|
|
|
|
|
using osu.Game.Tests.Visual;
|
2018-11-20 07:51:59 +00:00
|
|
|
|
using osuTK;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
|
|
|
|
namespace osu.Game.Rulesets.Taiko.Tests
|
|
|
|
|
{
|
|
|
|
|
[TestFixture]
|
2019-05-14 19:37:25 +00:00
|
|
|
|
public class TestSceneTaikoPlayfield : OsuTestScene
|
2018-04-13 09:19:50 +00:00
|
|
|
|
{
|
|
|
|
|
private const double default_duration = 1000;
|
|
|
|
|
private const float scroll_time = 1000;
|
|
|
|
|
|
|
|
|
|
protected override double TimePerAction => default_duration * 2;
|
|
|
|
|
|
|
|
|
|
private readonly Random rng = new Random(1337);
|
2019-03-19 14:44:15 +00:00
|
|
|
|
private DrawableTaikoRuleset drawableRuleset;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
private Container playfieldContainer;
|
|
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
2018-05-07 04:28:01 +00:00
|
|
|
|
private void load()
|
2018-04-13 09:19:50 +00:00
|
|
|
|
{
|
2018-08-06 04:01:27 +00:00
|
|
|
|
AddStep("Hit", () => addHitJudgement(false));
|
|
|
|
|
AddStep("Strong hit", () => addStrongHitJudgement(false));
|
2018-04-13 09:19:50 +00:00
|
|
|
|
AddStep("Kiai hit", () => addHitJudgement(true));
|
2018-08-06 04:01:27 +00:00
|
|
|
|
AddStep("Strong kiai hit", () => addStrongHitJudgement(true));
|
2018-04-13 09:19:50 +00:00
|
|
|
|
AddStep("Miss :(", addMissJudgement);
|
|
|
|
|
AddStep("DrumRoll", () => addDrumRoll(false));
|
|
|
|
|
AddStep("Strong DrumRoll", () => addDrumRoll(true));
|
|
|
|
|
AddStep("Swell", () => addSwell());
|
|
|
|
|
AddStep("Centre", () => addCentreHit(false));
|
|
|
|
|
AddStep("Strong Centre", () => addCentreHit(true));
|
|
|
|
|
AddStep("Rim", () => addRimHit(false));
|
|
|
|
|
AddStep("Strong Rim", () => addRimHit(true));
|
|
|
|
|
AddStep("Add bar line", () => addBarLine(false));
|
|
|
|
|
AddStep("Add major bar line", () => addBarLine(true));
|
2019-09-24 19:42:40 +00:00
|
|
|
|
AddStep("Add centre w/ bar line", () =>
|
|
|
|
|
{
|
|
|
|
|
addCentreHit(false);
|
|
|
|
|
addBarLine(true);
|
|
|
|
|
});
|
2018-04-13 09:19:50 +00:00
|
|
|
|
AddStep("Height test 1", () => changePlayfieldSize(1));
|
|
|
|
|
AddStep("Height test 2", () => changePlayfieldSize(2));
|
|
|
|
|
AddStep("Height test 3", () => changePlayfieldSize(3));
|
|
|
|
|
AddStep("Height test 4", () => changePlayfieldSize(4));
|
|
|
|
|
AddStep("Height test 5", () => changePlayfieldSize(5));
|
|
|
|
|
AddStep("Reset height", () => changePlayfieldSize(6));
|
|
|
|
|
|
|
|
|
|
var controlPointInfo = new ControlPointInfo();
|
2019-10-25 10:48:01 +00:00
|
|
|
|
controlPointInfo.Add(0, new TimingControlPoint());
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2019-05-31 05:40:53 +00:00
|
|
|
|
WorkingBeatmap beatmap = CreateWorkingBeatmap(new Beatmap
|
2018-04-13 09:19:50 +00:00
|
|
|
|
{
|
|
|
|
|
HitObjects = new List<HitObject> { new CentreHit() },
|
|
|
|
|
BeatmapInfo = new BeatmapInfo
|
|
|
|
|
{
|
|
|
|
|
BaseDifficulty = new BeatmapDifficulty(),
|
|
|
|
|
Metadata = new BeatmapMetadata
|
|
|
|
|
{
|
|
|
|
|
Artist = @"Unknown",
|
|
|
|
|
Title = @"Sample Beatmap",
|
|
|
|
|
AuthorString = @"peppy",
|
|
|
|
|
},
|
2018-05-07 04:28:01 +00:00
|
|
|
|
Ruleset = new TaikoRuleset().RulesetInfo
|
2018-04-13 09:19:50 +00:00
|
|
|
|
},
|
|
|
|
|
ControlPointInfo = controlPointInfo
|
2019-05-31 05:40:53 +00:00
|
|
|
|
});
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
|
|
|
|
Add(playfieldContainer = new Container
|
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
|
Height = 768,
|
2019-04-10 08:13:12 +00:00
|
|
|
|
Children = new[] { drawableRuleset = new DrawableTaikoRuleset(new TaikoRuleset(), beatmap, Array.Empty<Mod>()) }
|
2018-04-13 09:19:50 +00:00
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void changePlayfieldSize(int step)
|
|
|
|
|
{
|
|
|
|
|
double delay = 0;
|
|
|
|
|
|
|
|
|
|
// Add new hits
|
|
|
|
|
switch (step)
|
|
|
|
|
{
|
|
|
|
|
case 1:
|
|
|
|
|
addCentreHit(false);
|
|
|
|
|
break;
|
2019-04-01 03:44:46 +00:00
|
|
|
|
|
2018-04-13 09:19:50 +00:00
|
|
|
|
case 2:
|
|
|
|
|
addCentreHit(true);
|
|
|
|
|
break;
|
2019-04-01 03:44:46 +00:00
|
|
|
|
|
2018-04-13 09:19:50 +00:00
|
|
|
|
case 3:
|
|
|
|
|
addDrumRoll(false);
|
|
|
|
|
break;
|
2019-04-01 03:44:46 +00:00
|
|
|
|
|
2018-04-13 09:19:50 +00:00
|
|
|
|
case 4:
|
|
|
|
|
addDrumRoll(true);
|
|
|
|
|
break;
|
2019-04-01 03:44:46 +00:00
|
|
|
|
|
2018-04-13 09:19:50 +00:00
|
|
|
|
case 5:
|
|
|
|
|
addSwell();
|
|
|
|
|
delay = scroll_time - 100;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Tween playfield height
|
|
|
|
|
switch (step)
|
|
|
|
|
{
|
|
|
|
|
default:
|
|
|
|
|
playfieldContainer.Delay(delay).ResizeTo(new Vector2(1, rng.Next(25, 400)), 500);
|
|
|
|
|
break;
|
2019-04-01 03:44:46 +00:00
|
|
|
|
|
2018-04-13 09:19:50 +00:00
|
|
|
|
case 6:
|
|
|
|
|
playfieldContainer.Delay(delay).ResizeTo(new Vector2(1, TaikoPlayfield.DEFAULT_HEIGHT), 500);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void addHitJudgement(bool kiai)
|
|
|
|
|
{
|
|
|
|
|
HitResult hitResult = RNG.Next(2) == 0 ? HitResult.Good : HitResult.Great;
|
|
|
|
|
|
|
|
|
|
var cpi = new ControlPointInfo();
|
2019-10-25 10:48:01 +00:00
|
|
|
|
cpi.Add(0, new EffectControlPoint { KiaiMode = kiai });
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
|
|
|
|
Hit hit = new Hit();
|
|
|
|
|
hit.ApplyDefaults(cpi, new BeatmapDifficulty());
|
|
|
|
|
|
|
|
|
|
var h = new DrawableTestHit(hit) { X = RNG.NextSingle(hitResult == HitResult.Good ? -0.1f : -0.05f, hitResult == HitResult.Good ? 0.1f : 0.05f) };
|
|
|
|
|
|
2019-09-02 08:14:40 +00:00
|
|
|
|
((TaikoPlayfield)drawableRuleset.Playfield).OnNewResult(h, new JudgementResult(new HitObject(), new TaikoJudgement()) { Type = hitResult });
|
2018-08-06 04:01:27 +00:00
|
|
|
|
}
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2018-08-06 04:01:27 +00:00
|
|
|
|
private void addStrongHitJudgement(bool kiai)
|
|
|
|
|
{
|
|
|
|
|
HitResult hitResult = RNG.Next(2) == 0 ? HitResult.Good : HitResult.Great;
|
|
|
|
|
|
|
|
|
|
var cpi = new ControlPointInfo();
|
2019-10-25 10:48:01 +00:00
|
|
|
|
cpi.Add(0, new EffectControlPoint { KiaiMode = kiai });
|
2018-08-06 04:01:27 +00:00
|
|
|
|
|
|
|
|
|
Hit hit = new Hit();
|
|
|
|
|
hit.ApplyDefaults(cpi, new BeatmapDifficulty());
|
|
|
|
|
|
|
|
|
|
var h = new DrawableTestHit(hit) { X = RNG.NextSingle(hitResult == HitResult.Good ? -0.1f : -0.05f, hitResult == HitResult.Good ? 0.1f : 0.05f) };
|
|
|
|
|
|
2019-09-02 08:14:40 +00:00
|
|
|
|
((TaikoPlayfield)drawableRuleset.Playfield).OnNewResult(h, new JudgementResult(new HitObject(), new TaikoJudgement()) { Type = hitResult });
|
|
|
|
|
((TaikoPlayfield)drawableRuleset.Playfield).OnNewResult(new TestStrongNestedHit(h), new JudgementResult(new HitObject(), new TaikoStrongJudgement()) { Type = HitResult.Great });
|
2018-04-13 09:19:50 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void addMissJudgement()
|
|
|
|
|
{
|
2019-09-02 08:14:40 +00:00
|
|
|
|
((TaikoPlayfield)drawableRuleset.Playfield).OnNewResult(new DrawableTestHit(new Hit()), new JudgementResult(new HitObject(), new TaikoJudgement()) { Type = HitResult.Miss });
|
2018-04-13 09:19:50 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void addBarLine(bool major, double delay = scroll_time)
|
|
|
|
|
{
|
2019-03-19 14:44:15 +00:00
|
|
|
|
BarLine bl = new BarLine { StartTime = drawableRuleset.Playfield.Time.Current + delay };
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2019-03-19 14:44:15 +00:00
|
|
|
|
drawableRuleset.Playfield.Add(major ? new DrawableBarLineMajor(bl) : new DrawableBarLine(bl));
|
2018-04-13 09:19:50 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void addSwell(double duration = default_duration)
|
|
|
|
|
{
|
|
|
|
|
var swell = new Swell
|
|
|
|
|
{
|
2019-03-19 14:44:15 +00:00
|
|
|
|
StartTime = drawableRuleset.Playfield.Time.Current + scroll_time,
|
2018-04-13 09:19:50 +00:00
|
|
|
|
Duration = duration,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
swell.ApplyDefaults(new ControlPointInfo(), new BeatmapDifficulty());
|
|
|
|
|
|
2019-03-19 14:44:15 +00:00
|
|
|
|
drawableRuleset.Playfield.Add(new DrawableSwell(swell));
|
2018-04-13 09:19:50 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void addDrumRoll(bool strong, double duration = default_duration)
|
|
|
|
|
{
|
|
|
|
|
addBarLine(true);
|
|
|
|
|
addBarLine(true, scroll_time + duration);
|
|
|
|
|
|
|
|
|
|
var d = new DrumRoll
|
|
|
|
|
{
|
2019-03-19 14:44:15 +00:00
|
|
|
|
StartTime = drawableRuleset.Playfield.Time.Current + scroll_time,
|
2018-04-13 09:19:50 +00:00
|
|
|
|
IsStrong = strong,
|
|
|
|
|
Duration = duration,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
d.ApplyDefaults(new ControlPointInfo(), new BeatmapDifficulty());
|
|
|
|
|
|
2019-03-19 14:44:15 +00:00
|
|
|
|
drawableRuleset.Playfield.Add(new DrawableDrumRoll(d));
|
2018-04-13 09:19:50 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void addCentreHit(bool strong)
|
|
|
|
|
{
|
|
|
|
|
Hit h = new Hit
|
|
|
|
|
{
|
2019-03-19 14:44:15 +00:00
|
|
|
|
StartTime = drawableRuleset.Playfield.Time.Current + scroll_time,
|
2018-04-13 09:19:50 +00:00
|
|
|
|
IsStrong = strong
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
h.ApplyDefaults(new ControlPointInfo(), new BeatmapDifficulty());
|
|
|
|
|
|
2019-03-19 14:44:15 +00:00
|
|
|
|
drawableRuleset.Playfield.Add(new DrawableCentreHit(h));
|
2018-04-13 09:19:50 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void addRimHit(bool strong)
|
|
|
|
|
{
|
|
|
|
|
Hit h = new Hit
|
|
|
|
|
{
|
2019-03-19 14:44:15 +00:00
|
|
|
|
StartTime = drawableRuleset.Playfield.Time.Current + scroll_time,
|
2018-04-13 09:19:50 +00:00
|
|
|
|
IsStrong = strong
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
h.ApplyDefaults(new ControlPointInfo(), new BeatmapDifficulty());
|
|
|
|
|
|
2019-03-19 14:44:15 +00:00
|
|
|
|
drawableRuleset.Playfield.Add(new DrawableRimHit(h));
|
2018-04-13 09:19:50 +00:00
|
|
|
|
}
|
|
|
|
|
|
2018-08-14 05:28:05 +00:00
|
|
|
|
private class TestStrongNestedHit : DrawableStrongNestedHit
|
2018-08-06 04:01:27 +00:00
|
|
|
|
{
|
2018-08-14 05:28:05 +00:00
|
|
|
|
public TestStrongNestedHit(DrawableHitObject mainObject)
|
2019-10-21 09:10:00 +00:00
|
|
|
|
: base(new StrongHitObject { StartTime = mainObject.HitObject.StartTime }, mainObject)
|
2018-08-06 04:01:27 +00:00
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override bool OnPressed(TaikoAction action) => false;
|
|
|
|
|
}
|
|
|
|
|
|
2018-04-13 09:19:50 +00:00
|
|
|
|
private class DrawableTestHit : DrawableHitObject<TaikoHitObject>
|
|
|
|
|
{
|
|
|
|
|
public DrawableTestHit(TaikoHitObject hitObject)
|
|
|
|
|
: base(hitObject)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|