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
|
|
|
|
|
2017-09-18 13:32:49 +00:00
|
|
|
|
using System;
|
2020-12-12 22:50:12 +00:00
|
|
|
|
using System.Collections.Generic;
|
2020-12-12 21:42:40 +00:00
|
|
|
|
using System.Linq;
|
2017-09-18 13:32:49 +00:00
|
|
|
|
using NUnit.Framework;
|
|
|
|
|
using osu.Framework.Graphics;
|
2020-01-09 04:43:44 +00:00
|
|
|
|
using osu.Framework.Utils;
|
2020-12-12 22:50:12 +00:00
|
|
|
|
using osu.Game.Audio;
|
2017-09-18 13:32:49 +00:00
|
|
|
|
using osu.Game.Beatmaps;
|
|
|
|
|
using osu.Game.Beatmaps.ControlPoints;
|
2018-08-02 11:36:08 +00:00
|
|
|
|
using osu.Game.Rulesets.Judgements;
|
2019-09-06 06:24:00 +00:00
|
|
|
|
using osu.Game.Rulesets.Scoring;
|
2017-09-18 13:32:49 +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;
|
2018-11-20 07:51:59 +00:00
|
|
|
|
using osuTK;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2017-09-18 13:32:49 +00:00
|
|
|
|
namespace osu.Game.Rulesets.Taiko.Tests
|
|
|
|
|
{
|
|
|
|
|
[TestFixture]
|
2020-09-26 18:36:38 +00:00
|
|
|
|
public partial class TestSceneHits : DrawableTaikoRulesetTestScene
|
2017-09-18 13:32:49 +00:00
|
|
|
|
{
|
2020-04-27 03:17:36 +00:00
|
|
|
|
private const double default_duration = 3000;
|
2017-09-18 13:32:49 +00:00
|
|
|
|
private const float scroll_time = 1000;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2017-09-18 13:32:49 +00:00
|
|
|
|
protected override double TimePerAction => default_duration * 2;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2017-09-18 13:32:49 +00:00
|
|
|
|
private readonly Random rng = new Random(1337);
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2020-10-02 09:18:14 +00:00
|
|
|
|
[Test]
|
|
|
|
|
public void TestVariousHits()
|
2017-09-18 13:32:49 +00:00
|
|
|
|
{
|
2018-08-06 04:01:27 +00:00
|
|
|
|
AddStep("Hit", () => addHitJudgement(false));
|
|
|
|
|
AddStep("Strong hit", () => addStrongHitJudgement(false));
|
2017-09-18 13:32:49 +00:00
|
|
|
|
AddStep("Kiai hit", () => addHitJudgement(true));
|
2018-08-06 04:01:27 +00:00
|
|
|
|
AddStep("Strong kiai hit", () => addStrongHitJudgement(true));
|
2017-09-18 13:32:49 +00:00
|
|
|
|
AddStep("Miss :(", addMissJudgement);
|
|
|
|
|
AddStep("DrumRoll", () => addDrumRoll(false));
|
|
|
|
|
AddStep("Strong DrumRoll", () => addDrumRoll(true));
|
2020-04-27 03:17:36 +00:00
|
|
|
|
AddStep("Kiai DrumRoll", () => addDrumRoll(true, kiai: true));
|
2017-09-18 13:32:49 +00:00
|
|
|
|
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);
|
|
|
|
|
});
|
2017-09-18 13:32:49 +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));
|
|
|
|
|
}
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2017-09-18 13:32:49 +00:00
|
|
|
|
private void changePlayfieldSize(int step)
|
|
|
|
|
{
|
|
|
|
|
double delay = 0;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2017-09-18 13:32:49 +00:00
|
|
|
|
// Add new hits
|
|
|
|
|
switch (step)
|
|
|
|
|
{
|
|
|
|
|
case 1:
|
|
|
|
|
addCentreHit(false);
|
|
|
|
|
break;
|
2019-04-01 03:44:46 +00:00
|
|
|
|
|
2017-09-18 13:32:49 +00:00
|
|
|
|
case 2:
|
|
|
|
|
addCentreHit(true);
|
|
|
|
|
break;
|
2019-04-01 03:44:46 +00:00
|
|
|
|
|
2017-09-18 13:32:49 +00:00
|
|
|
|
case 3:
|
|
|
|
|
addDrumRoll(false);
|
|
|
|
|
break;
|
2019-04-01 03:44:46 +00:00
|
|
|
|
|
2017-09-18 13:32:49 +00:00
|
|
|
|
case 4:
|
|
|
|
|
addDrumRoll(true);
|
|
|
|
|
break;
|
2019-04-01 03:44:46 +00:00
|
|
|
|
|
2017-09-18 13:32:49 +00:00
|
|
|
|
case 5:
|
|
|
|
|
addSwell();
|
|
|
|
|
delay = scroll_time - 100;
|
|
|
|
|
break;
|
|
|
|
|
}
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2017-09-18 13:32:49 +00:00
|
|
|
|
// Tween playfield height
|
|
|
|
|
switch (step)
|
|
|
|
|
{
|
|
|
|
|
default:
|
2020-09-26 18:36:38 +00:00
|
|
|
|
PlayfieldContainer.Delay(delay).ResizeTo(new Vector2(1, rng.Next(25, 400)), 500);
|
2017-09-18 13:32:49 +00:00
|
|
|
|
break;
|
2019-04-01 03:44:46 +00:00
|
|
|
|
|
2017-09-18 13:32:49 +00:00
|
|
|
|
case 6:
|
2020-12-12 23:00:37 +00:00
|
|
|
|
PlayfieldContainer.Delay(delay).ResizeTo(new Vector2(1, DEFAULT_PLAYFIELD_CONTAINER_HEIGHT), 500);
|
2017-09-18 13:32:49 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2017-09-18 13:32:49 +00:00
|
|
|
|
private void addHitJudgement(bool kiai)
|
|
|
|
|
{
|
2020-09-29 08:16:55 +00:00
|
|
|
|
HitResult hitResult = RNG.Next(2) == 0 ? HitResult.Ok : HitResult.Great;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2021-03-14 14:56:34 +00:00
|
|
|
|
Hit hit = new Hit { StartTime = DrawableRuleset.Playfield.Time.Current };
|
2020-12-12 21:48:22 +00:00
|
|
|
|
var h = new DrawableTestHit(hit, kiai: kiai) { X = RNG.NextSingle(hitResult == HitResult.Ok ? -0.1f : -0.05f, hitResult == HitResult.Ok ? 0.1f : 0.05f) };
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2020-09-26 18:36:38 +00:00
|
|
|
|
DrawableRuleset.Playfield.Add(h);
|
2020-04-28 02:07:31 +00:00
|
|
|
|
|
2021-03-14 14:56:34 +00:00
|
|
|
|
((TaikoPlayfield)DrawableRuleset.Playfield).OnNewResult(h, new JudgementResult(hit, 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)
|
|
|
|
|
{
|
2020-09-29 08:16:55 +00:00
|
|
|
|
HitResult hitResult = RNG.Next(2) == 0 ? HitResult.Ok : HitResult.Great;
|
2018-08-06 04:01:27 +00:00
|
|
|
|
|
2020-12-12 22:50:12 +00:00
|
|
|
|
Hit hit = new Hit
|
|
|
|
|
{
|
2021-03-14 14:56:34 +00:00
|
|
|
|
StartTime = DrawableRuleset.Playfield.Time.Current,
|
2020-12-12 22:50:12 +00:00
|
|
|
|
IsStrong = true,
|
|
|
|
|
Samples = createSamples(strong: true)
|
|
|
|
|
};
|
2020-12-12 21:48:22 +00:00
|
|
|
|
var h = new DrawableTestHit(hit, kiai: kiai) { X = RNG.NextSingle(hitResult == HitResult.Ok ? -0.1f : -0.05f, hitResult == HitResult.Ok ? 0.1f : 0.05f) };
|
2018-08-06 04:01:27 +00:00
|
|
|
|
|
2020-09-26 18:36:38 +00:00
|
|
|
|
DrawableRuleset.Playfield.Add(h);
|
2020-04-28 02:07:31 +00:00
|
|
|
|
|
2021-03-14 14:56:34 +00:00
|
|
|
|
((TaikoPlayfield)DrawableRuleset.Playfield).OnNewResult(h, new JudgementResult(hit, new TaikoJudgement()) { Type = hitResult });
|
|
|
|
|
((TaikoPlayfield)DrawableRuleset.Playfield).OnNewResult(h.NestedHitObjects.Single(), new JudgementResult(hit.NestedHitObjects.Single(), new TaikoStrongJudgement()) { Type = HitResult.Great });
|
2017-09-18 13:32:49 +00:00
|
|
|
|
}
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2017-09-18 13:32:49 +00:00
|
|
|
|
private void addMissJudgement()
|
|
|
|
|
{
|
2020-09-20 18:44:31 +00:00
|
|
|
|
DrawableTestHit h;
|
2020-12-12 21:52:01 +00:00
|
|
|
|
DrawableRuleset.Playfield.Add(h = new DrawableTestHit(new Hit { StartTime = DrawableRuleset.Playfield.Time.Current }, HitResult.Miss)
|
|
|
|
|
{
|
|
|
|
|
Alpha = 0
|
|
|
|
|
});
|
|
|
|
|
((TaikoPlayfield)DrawableRuleset.Playfield).OnNewResult(h, new JudgementResult(h.HitObject, new TaikoJudgement()) { Type = HitResult.Miss });
|
2017-09-18 13:32:49 +00:00
|
|
|
|
}
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2017-09-18 13:32:49 +00:00
|
|
|
|
private void addBarLine(bool major, double delay = scroll_time)
|
|
|
|
|
{
|
2020-12-13 18:59:07 +00:00
|
|
|
|
BarLine bl = new BarLine
|
|
|
|
|
{
|
|
|
|
|
StartTime = DrawableRuleset.Playfield.Time.Current + delay,
|
|
|
|
|
Major = major
|
|
|
|
|
};
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2020-12-13 19:12:54 +00:00
|
|
|
|
DrawableRuleset.Playfield.Add(bl);
|
2017-09-18 13:32:49 +00:00
|
|
|
|
}
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2017-09-18 13:32:49 +00:00
|
|
|
|
private void addSwell(double duration = default_duration)
|
|
|
|
|
{
|
2017-12-25 06:35:28 +00:00
|
|
|
|
var swell = new Swell
|
2017-09-18 13:32:49 +00:00
|
|
|
|
{
|
2020-09-26 18:36:38 +00:00
|
|
|
|
StartTime = DrawableRuleset.Playfield.Time.Current + scroll_time,
|
2017-09-18 13:32:49 +00:00
|
|
|
|
Duration = duration,
|
2017-12-25 06:35:28 +00:00
|
|
|
|
};
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2017-12-25 06:35:28 +00:00
|
|
|
|
swell.ApplyDefaults(new ControlPointInfo(), new BeatmapDifficulty());
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2020-09-26 18:36:38 +00:00
|
|
|
|
DrawableRuleset.Playfield.Add(new DrawableSwell(swell));
|
2017-09-18 13:32:49 +00:00
|
|
|
|
}
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2020-04-27 03:17:36 +00:00
|
|
|
|
private void addDrumRoll(bool strong, double duration = default_duration, bool kiai = false)
|
2017-09-18 13:32:49 +00:00
|
|
|
|
{
|
|
|
|
|
addBarLine(true);
|
|
|
|
|
addBarLine(true, scroll_time + duration);
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2017-09-18 13:32:49 +00:00
|
|
|
|
var d = new DrumRoll
|
|
|
|
|
{
|
2020-09-26 18:36:38 +00:00
|
|
|
|
StartTime = DrawableRuleset.Playfield.Time.Current + scroll_time,
|
2017-09-18 13:32:49 +00:00
|
|
|
|
IsStrong = strong,
|
2020-12-12 22:50:12 +00:00
|
|
|
|
Samples = createSamples(strong: strong),
|
2017-09-18 13:32:49 +00:00
|
|
|
|
Duration = duration,
|
2020-04-27 03:17:36 +00:00
|
|
|
|
TickRate = 8,
|
2017-09-18 13:32:49 +00:00
|
|
|
|
};
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2020-04-27 03:17:36 +00:00
|
|
|
|
var cpi = new ControlPointInfo();
|
|
|
|
|
cpi.Add(-10000, new EffectControlPoint { KiaiMode = kiai });
|
|
|
|
|
|
|
|
|
|
d.ApplyDefaults(cpi, new BeatmapDifficulty());
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2020-09-26 18:36:38 +00:00
|
|
|
|
DrawableRuleset.Playfield.Add(new DrawableDrumRoll(d));
|
2017-09-18 13:32:49 +00:00
|
|
|
|
}
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2017-09-18 13:32:49 +00:00
|
|
|
|
private void addCentreHit(bool strong)
|
|
|
|
|
{
|
|
|
|
|
Hit h = new Hit
|
|
|
|
|
{
|
2020-09-26 18:36:38 +00:00
|
|
|
|
StartTime = DrawableRuleset.Playfield.Time.Current + scroll_time,
|
2020-12-12 22:50:12 +00:00
|
|
|
|
IsStrong = strong,
|
|
|
|
|
Samples = createSamples(HitType.Centre, strong)
|
2017-09-18 13:32:49 +00:00
|
|
|
|
};
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2017-12-25 06:35:28 +00:00
|
|
|
|
h.ApplyDefaults(new ControlPointInfo(), new BeatmapDifficulty());
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2020-09-26 18:36:38 +00:00
|
|
|
|
DrawableRuleset.Playfield.Add(new DrawableHit(h));
|
2017-09-18 13:32:49 +00:00
|
|
|
|
}
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2017-09-18 13:32:49 +00:00
|
|
|
|
private void addRimHit(bool strong)
|
|
|
|
|
{
|
|
|
|
|
Hit h = new Hit
|
|
|
|
|
{
|
2020-09-26 18:36:38 +00:00
|
|
|
|
StartTime = DrawableRuleset.Playfield.Time.Current + scroll_time,
|
2020-12-12 22:50:12 +00:00
|
|
|
|
IsStrong = strong,
|
|
|
|
|
Samples = createSamples(HitType.Rim, strong)
|
2017-09-18 13:32:49 +00:00
|
|
|
|
};
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2017-12-25 06:35:28 +00:00
|
|
|
|
h.ApplyDefaults(new ControlPointInfo(), new BeatmapDifficulty());
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2020-09-26 18:36:38 +00:00
|
|
|
|
DrawableRuleset.Playfield.Add(new DrawableHit(h));
|
2017-09-18 13:32:49 +00:00
|
|
|
|
}
|
2020-12-12 22:50:12 +00:00
|
|
|
|
|
|
|
|
|
// TODO: can be removed if a better way of handling colour/strong type and samples is developed
|
|
|
|
|
private IList<HitSampleInfo> createSamples(HitType? hitType = null, bool strong = false)
|
|
|
|
|
{
|
|
|
|
|
var samples = new List<HitSampleInfo>();
|
|
|
|
|
|
|
|
|
|
if (hitType == HitType.Rim)
|
|
|
|
|
samples.Add(new HitSampleInfo(HitSampleInfo.HIT_CLAP));
|
|
|
|
|
|
|
|
|
|
if (strong)
|
|
|
|
|
samples.Add(new HitSampleInfo(HitSampleInfo.HIT_FINISH));
|
|
|
|
|
|
|
|
|
|
return samples;
|
|
|
|
|
}
|
2017-09-18 13:32:49 +00:00
|
|
|
|
}
|
|
|
|
|
}
|