2017-03-21 06:09:54 +00: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-08-04 06:37:31 +00:00
|
|
|
|
using System;
|
2017-03-28 02:18:12 +00:00
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
|
using osu.Framework.Graphics.Containers;
|
2017-03-21 06:54:57 +00:00
|
|
|
|
using osu.Framework.MathUtils;
|
2017-04-05 00:57:22 +00:00
|
|
|
|
using osu.Framework.Timing;
|
2017-04-18 07:05:58 +00:00
|
|
|
|
using osu.Game.Rulesets.Objects.Drawables;
|
|
|
|
|
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;
|
2017-08-04 06:37:31 +00:00
|
|
|
|
using OpenTK;
|
2017-08-03 04:03:46 +00:00
|
|
|
|
using osu.Game.Beatmaps.ControlPoints;
|
|
|
|
|
using osu.Game.Beatmaps;
|
2017-08-09 07:19:20 +00:00
|
|
|
|
using osu.Desktop.Tests.Beatmaps;
|
|
|
|
|
using System.Collections.Generic;
|
2017-08-20 13:21:16 +00:00
|
|
|
|
using osu.Framework.Allocation;
|
|
|
|
|
using osu.Game.Rulesets;
|
2017-08-09 07:19:20 +00:00
|
|
|
|
using osu.Game.Rulesets.Objects;
|
2017-03-21 06:09:54 +00:00
|
|
|
|
|
2017-08-04 06:37:31 +00:00
|
|
|
|
namespace osu.Desktop.Tests.Visual
|
2017-03-21 06:09:54 +00:00
|
|
|
|
{
|
2017-08-04 06:37:31 +00:00
|
|
|
|
internal class TestCaseTaikoPlayfield : OsuTestCase
|
2017-03-21 06:09:54 +00:00
|
|
|
|
{
|
2017-08-03 03:41:53 +00:00
|
|
|
|
private const double default_duration = 1000;
|
2017-04-10 05:28:28 +00:00
|
|
|
|
private const float scroll_time = 1000;
|
2017-03-21 06:09:54 +00:00
|
|
|
|
|
2017-04-10 05:28:28 +00:00
|
|
|
|
public override string Description => "Taiko playfield";
|
2017-03-21 06:54:57 +00:00
|
|
|
|
|
2017-04-05 04:53:29 +00:00
|
|
|
|
protected override double TimePerAction => default_duration * 2;
|
|
|
|
|
|
2017-04-10 05:28:28 +00:00
|
|
|
|
private readonly Random rng = new Random(1337);
|
2017-08-20 13:21:16 +00:00
|
|
|
|
private TaikoRulesetContainer rulesetContainer;
|
|
|
|
|
private Container playfieldContainer;
|
2017-04-04 01:32:57 +00:00
|
|
|
|
|
2017-08-20 13:21:16 +00:00
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
|
private void load(RulesetStore rulesets)
|
2017-03-21 06:09:54 +00:00
|
|
|
|
{
|
2017-08-03 04:03:46 +00:00
|
|
|
|
AddStep("Hit!", () => addHitJudgement(false));
|
|
|
|
|
AddStep("Kiai hit", () => addHitJudgement(true));
|
2017-03-31 08:55:07 +00:00
|
|
|
|
AddStep("Miss :(", addMissJudgement);
|
2017-04-01 07:02:32 +00:00
|
|
|
|
AddStep("DrumRoll", () => addDrumRoll(false));
|
|
|
|
|
AddStep("Strong DrumRoll", () => addDrumRoll(true));
|
2017-04-05 04:53:29 +00:00
|
|
|
|
AddStep("Swell", () => addSwell());
|
2017-03-31 08:55:07 +00:00
|
|
|
|
AddStep("Centre", () => addCentreHit(false));
|
|
|
|
|
AddStep("Strong Centre", () => addCentreHit(true));
|
|
|
|
|
AddStep("Rim", () => addRimHit(false));
|
|
|
|
|
AddStep("Strong Rim", () => addRimHit(true));
|
2017-04-03 01:04:13 +00:00
|
|
|
|
AddStep("Add bar line", () => addBarLine(false));
|
|
|
|
|
AddStep("Add major bar line", () => addBarLine(true));
|
2017-04-10 05:28:28 +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));
|
2017-04-12 03:37:20 +00:00
|
|
|
|
AddStep("Reset height", () => changePlayfieldSize(6));
|
2017-04-05 00:57:22 +00:00
|
|
|
|
|
2017-08-09 07:19:20 +00:00
|
|
|
|
var controlPointInfo = new ControlPointInfo();
|
2017-08-09 07:46:22 +00:00
|
|
|
|
controlPointInfo.TimingPoints.Add(new TimingControlPoint());
|
2017-08-09 07:19:20 +00:00
|
|
|
|
|
|
|
|
|
WorkingBeatmap beatmap = new TestWorkingBeatmap(new Beatmap
|
|
|
|
|
{
|
|
|
|
|
HitObjects = new List<HitObject> { new CentreHit() },
|
|
|
|
|
BeatmapInfo = new BeatmapInfo
|
|
|
|
|
{
|
|
|
|
|
Difficulty = new BeatmapDifficulty(),
|
|
|
|
|
Metadata = new BeatmapMetadata
|
|
|
|
|
{
|
|
|
|
|
Artist = @"Unknown",
|
|
|
|
|
Title = @"Sample Beatmap",
|
|
|
|
|
Author = @"peppy",
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
ControlPointInfo = controlPointInfo
|
|
|
|
|
});
|
|
|
|
|
|
2017-08-09 07:46:22 +00:00
|
|
|
|
var rateAdjustClock = new StopwatchClock(true) { Rate = 1 };
|
2017-04-05 00:57:22 +00:00
|
|
|
|
|
2017-04-12 03:36:31 +00:00
|
|
|
|
Add(playfieldContainer = new Container
|
2017-03-21 06:09:54 +00:00
|
|
|
|
{
|
2017-04-12 03:36:31 +00:00
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
|
Origin = Anchor.Centre,
|
2017-03-28 02:18:12 +00:00
|
|
|
|
RelativeSizeAxes = Axes.X,
|
2017-08-09 07:46:22 +00:00
|
|
|
|
Height = 768,
|
2017-04-12 03:36:31 +00:00
|
|
|
|
Clock = new FramedClock(rateAdjustClock),
|
2017-08-20 13:21:16 +00:00
|
|
|
|
Children = new[] { rulesetContainer = new TaikoRulesetContainer(rulesets.GetRuleset(1).CreateInstance(), beatmap, true) }
|
2017-03-21 06:09:54 +00:00
|
|
|
|
});
|
|
|
|
|
}
|
2017-03-21 06:54:57 +00:00
|
|
|
|
|
2017-04-10 05:28:28 +00:00
|
|
|
|
private void changePlayfieldSize(int step)
|
|
|
|
|
{
|
2017-07-17 13:51:21 +00:00
|
|
|
|
double delay = 0;
|
|
|
|
|
|
2017-04-12 03:37:20 +00:00
|
|
|
|
// Add new hits
|
2017-04-10 05:28:28 +00:00
|
|
|
|
switch (step)
|
|
|
|
|
{
|
|
|
|
|
case 1:
|
|
|
|
|
addCentreHit(false);
|
|
|
|
|
break;
|
|
|
|
|
case 2:
|
|
|
|
|
addCentreHit(true);
|
|
|
|
|
break;
|
|
|
|
|
case 3:
|
|
|
|
|
addDrumRoll(false);
|
|
|
|
|
break;
|
|
|
|
|
case 4:
|
|
|
|
|
addDrumRoll(true);
|
|
|
|
|
break;
|
|
|
|
|
case 5:
|
2017-08-03 05:08:24 +00:00
|
|
|
|
addSwell();
|
2017-07-17 13:51:21 +00:00
|
|
|
|
delay = scroll_time - 100;
|
2017-04-10 05:28:28 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2017-04-12 03:37:20 +00:00
|
|
|
|
// Tween playfield height
|
|
|
|
|
switch (step)
|
|
|
|
|
{
|
|
|
|
|
default:
|
2017-07-17 13:51:21 +00:00
|
|
|
|
playfieldContainer.Delay(delay).ResizeTo(new Vector2(1, rng.Next(25, 400)), 500);
|
2017-04-12 03:37:20 +00:00
|
|
|
|
break;
|
|
|
|
|
case 6:
|
2017-08-03 06:17:23 +00:00
|
|
|
|
playfieldContainer.Delay(delay).ResizeTo(new Vector2(1, TaikoPlayfield.DEFAULT_HEIGHT), 500);
|
2017-04-12 03:37:20 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
2017-04-10 05:28:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
2017-08-03 04:03:46 +00:00
|
|
|
|
private void addHitJudgement(bool kiai)
|
2017-03-21 06:54:57 +00:00
|
|
|
|
{
|
2017-03-21 16:42:40 +00:00
|
|
|
|
TaikoHitResult hitResult = RNG.Next(2) == 0 ? TaikoHitResult.Good : TaikoHitResult.Great;
|
2017-03-21 06:54:57 +00:00
|
|
|
|
|
2017-08-03 04:03:46 +00:00
|
|
|
|
var cpi = new ControlPointInfo();
|
|
|
|
|
cpi.EffectPoints.Add(new EffectControlPoint
|
|
|
|
|
{
|
|
|
|
|
KiaiMode = kiai
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
Hit hit = new Hit();
|
|
|
|
|
hit.ApplyDefaults(cpi, new BeatmapDifficulty());
|
|
|
|
|
|
|
|
|
|
var h = new DrawableTestHit(hit)
|
2017-03-21 06:54:57 +00:00
|
|
|
|
{
|
2017-03-21 16:42:40 +00:00
|
|
|
|
X = RNG.NextSingle(hitResult == TaikoHitResult.Good ? -0.1f : -0.05f, hitResult == TaikoHitResult.Good ? 0.1f : 0.05f),
|
2017-03-23 10:00:18 +00:00
|
|
|
|
Judgement = new TaikoJudgement
|
2017-03-21 06:54:57 +00:00
|
|
|
|
{
|
|
|
|
|
Result = HitResult.Hit,
|
2017-03-21 16:42:40 +00:00
|
|
|
|
TaikoResult = hitResult,
|
2017-04-09 20:08:05 +00:00
|
|
|
|
TimeOffset = 0
|
2017-03-21 06:54:57 +00:00
|
|
|
|
}
|
2017-04-09 20:08:05 +00:00
|
|
|
|
};
|
|
|
|
|
|
2017-08-09 07:19:20 +00:00
|
|
|
|
rulesetContainer.Playfield.OnJudgement(h);
|
2017-04-09 20:08:05 +00:00
|
|
|
|
|
|
|
|
|
if (RNG.Next(10) == 0)
|
|
|
|
|
{
|
|
|
|
|
h.Judgement.SecondHit = true;
|
2017-08-09 07:19:20 +00:00
|
|
|
|
rulesetContainer.Playfield.OnJudgement(h);
|
2017-04-09 20:08:05 +00:00
|
|
|
|
}
|
2017-03-21 06:54:57 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void addMissJudgement()
|
|
|
|
|
{
|
2017-08-09 07:19:20 +00:00
|
|
|
|
rulesetContainer.Playfield.OnJudgement(new DrawableTestHit(new Hit())
|
2017-03-21 06:54:57 +00:00
|
|
|
|
{
|
2017-03-23 10:00:18 +00:00
|
|
|
|
Judgement = new TaikoJudgement
|
2017-03-21 06:54:57 +00:00
|
|
|
|
{
|
|
|
|
|
Result = HitResult.Miss,
|
2017-03-30 01:51:14 +00:00
|
|
|
|
TimeOffset = 0
|
2017-03-21 06:54:57 +00:00
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2017-04-05 04:53:29 +00:00
|
|
|
|
private void addBarLine(bool major, double delay = scroll_time)
|
2017-03-21 12:27:20 +00:00
|
|
|
|
{
|
2017-08-09 07:19:20 +00:00
|
|
|
|
BarLine bl = new BarLine { StartTime = rulesetContainer.Playfield.Time.Current + delay };
|
2017-03-21 12:27:20 +00:00
|
|
|
|
|
2017-08-09 07:19:20 +00:00
|
|
|
|
rulesetContainer.Playfield.Add(major ? new DrawableBarLineMajor(bl) : new DrawableBarLine(bl));
|
2017-03-21 12:27:20 +00:00
|
|
|
|
}
|
|
|
|
|
|
2017-04-05 04:53:29 +00:00
|
|
|
|
private void addSwell(double duration = default_duration)
|
2017-03-28 06:05:45 +00:00
|
|
|
|
{
|
2017-08-09 07:19:20 +00:00
|
|
|
|
rulesetContainer.Playfield.Add(new DrawableSwell(new Swell
|
2017-03-28 06:05:45 +00:00
|
|
|
|
{
|
2017-08-09 07:19:20 +00:00
|
|
|
|
StartTime = rulesetContainer.Playfield.Time.Current + scroll_time,
|
2017-04-05 04:53:29 +00:00
|
|
|
|
Duration = duration,
|
2017-03-28 06:05:45 +00:00
|
|
|
|
}));
|
|
|
|
|
}
|
2017-04-06 08:21:18 +00:00
|
|
|
|
|
2017-04-05 04:53:29 +00:00
|
|
|
|
private void addDrumRoll(bool strong, double duration = default_duration)
|
2017-03-28 07:50:06 +00:00
|
|
|
|
{
|
2017-04-05 04:53:29 +00:00
|
|
|
|
addBarLine(true);
|
|
|
|
|
addBarLine(true, scroll_time + duration);
|
|
|
|
|
|
2017-03-28 07:50:06 +00:00
|
|
|
|
var d = new DrumRoll
|
|
|
|
|
{
|
2017-08-09 07:19:20 +00:00
|
|
|
|
StartTime = rulesetContainer.Playfield.Time.Current + scroll_time,
|
2017-04-05 01:01:40 +00:00
|
|
|
|
IsStrong = strong,
|
2017-04-05 04:53:29 +00:00
|
|
|
|
Duration = duration,
|
2017-03-28 07:50:06 +00:00
|
|
|
|
};
|
|
|
|
|
|
2017-08-09 07:19:20 +00:00
|
|
|
|
rulesetContainer.Playfield.Add(new DrawableDrumRoll(d));
|
2017-03-28 07:50:06 +00:00
|
|
|
|
}
|
2017-03-28 06:05:45 +00:00
|
|
|
|
|
2017-03-28 02:18:12 +00:00
|
|
|
|
private void addCentreHit(bool strong)
|
|
|
|
|
{
|
|
|
|
|
Hit h = new Hit
|
|
|
|
|
{
|
2017-08-09 07:19:20 +00:00
|
|
|
|
StartTime = rulesetContainer.Playfield.Time.Current + scroll_time,
|
2017-08-03 03:41:53 +00:00
|
|
|
|
IsStrong = strong
|
2017-03-28 02:18:12 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
if (strong)
|
2017-08-09 07:19:20 +00:00
|
|
|
|
rulesetContainer.Playfield.Add(new DrawableCentreHitStrong(h));
|
2017-03-28 02:18:12 +00:00
|
|
|
|
else
|
2017-08-09 07:19:20 +00:00
|
|
|
|
rulesetContainer.Playfield.Add(new DrawableCentreHit(h));
|
2017-03-28 02:18:12 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void addRimHit(bool strong)
|
|
|
|
|
{
|
|
|
|
|
Hit h = new Hit
|
|
|
|
|
{
|
2017-08-09 07:19:20 +00:00
|
|
|
|
StartTime = rulesetContainer.Playfield.Time.Current + scroll_time,
|
2017-08-03 03:41:53 +00:00
|
|
|
|
IsStrong = strong
|
2017-03-28 02:18:12 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
if (strong)
|
2017-08-09 07:19:20 +00:00
|
|
|
|
rulesetContainer.Playfield.Add(new DrawableRimHitStrong(h));
|
2017-03-28 02:18:12 +00:00
|
|
|
|
else
|
2017-08-09 07:19:20 +00:00
|
|
|
|
rulesetContainer.Playfield.Add(new DrawableRimHit(h));
|
2017-03-28 02:18:12 +00:00
|
|
|
|
}
|
|
|
|
|
|
2017-03-23 10:00:18 +00:00
|
|
|
|
private class DrawableTestHit : DrawableHitObject<TaikoHitObject, TaikoJudgement>
|
2017-03-21 06:54:57 +00:00
|
|
|
|
{
|
|
|
|
|
public DrawableTestHit(TaikoHitObject hitObject)
|
|
|
|
|
: base(hitObject)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2017-03-23 10:00:18 +00:00
|
|
|
|
protected override TaikoJudgement CreateJudgement() => new TaikoJudgement();
|
2017-03-21 06:54:57 +00:00
|
|
|
|
|
|
|
|
|
protected override void UpdateState(ArmedState state)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
}
|
2017-03-21 06:09:54 +00:00
|
|
|
|
}
|
|
|
|
|
}
|