mirror of
https://github.com/ppy/osu.git
synced 2024-09-21 19:27:24 +08:00
Merge pull request #11159 from bdach/taiko-hits-test-cleanup
Refactor and restore taiko hits test scene to a working state
This commit is contained in:
commit
94d737e51b
@ -16,6 +16,8 @@ namespace osu.Game.Rulesets.Taiko.Tests
|
|||||||
{
|
{
|
||||||
public abstract class DrawableTaikoRulesetTestScene : OsuTestScene
|
public abstract class DrawableTaikoRulesetTestScene : OsuTestScene
|
||||||
{
|
{
|
||||||
|
protected const int DEFAULT_PLAYFIELD_CONTAINER_HEIGHT = 768;
|
||||||
|
|
||||||
protected DrawableTaikoRuleset DrawableRuleset { get; private set; }
|
protected DrawableTaikoRuleset DrawableRuleset { get; private set; }
|
||||||
protected Container PlayfieldContainer { get; private set; }
|
protected Container PlayfieldContainer { get; private set; }
|
||||||
|
|
||||||
@ -44,10 +46,10 @@ namespace osu.Game.Rulesets.Taiko.Tests
|
|||||||
|
|
||||||
Add(PlayfieldContainer = new Container
|
Add(PlayfieldContainer = new Container
|
||||||
{
|
{
|
||||||
Anchor = Anchor.Centre,
|
Anchor = Anchor.TopCentre,
|
||||||
Origin = Anchor.Centre,
|
Origin = Anchor.TopCentre,
|
||||||
RelativeSizeAxes = Axes.X,
|
RelativeSizeAxes = Axes.X,
|
||||||
Height = 768,
|
Height = DEFAULT_PLAYFIELD_CONTAINER_HEIGHT,
|
||||||
Children = new[] { DrawableRuleset = new DrawableTaikoRuleset(new TaikoRuleset(), beatmap.GetPlayableBeatmap(new TaikoRuleset().RulesetInfo)) }
|
Children = new[] { DrawableRuleset = new DrawableTaikoRuleset(new TaikoRuleset(), beatmap.GetPlayableBeatmap(new TaikoRuleset().RulesetInfo)) }
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -13,12 +13,15 @@ namespace osu.Game.Rulesets.Taiko.Tests
|
|||||||
{
|
{
|
||||||
public readonly HitResult Type;
|
public readonly HitResult Type;
|
||||||
|
|
||||||
public DrawableTestHit(Hit hit, HitResult type = HitResult.Great)
|
public DrawableTestHit(Hit hit, HitResult type = HitResult.Great, bool kiai = false)
|
||||||
: base(hit)
|
: base(hit)
|
||||||
{
|
{
|
||||||
Type = type;
|
Type = type;
|
||||||
|
|
||||||
HitObject.ApplyDefaults(new ControlPointInfo(), new BeatmapDifficulty());
|
var controlPoints = new ControlPointInfo();
|
||||||
|
controlPoints.Add(0, new EffectControlPoint { KiaiMode = kiai });
|
||||||
|
|
||||||
|
HitObject.ApplyDefaults(controlPoints, new BeatmapDifficulty());
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void UpdateInitialTransforms()
|
protected override void UpdateInitialTransforms()
|
||||||
|
@ -2,14 +2,16 @@
|
|||||||
// See the LICENCE file in the repository root for full licence text.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Utils;
|
using osu.Framework.Utils;
|
||||||
|
using osu.Game.Audio;
|
||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
using osu.Game.Beatmaps.ControlPoints;
|
using osu.Game.Beatmaps.ControlPoints;
|
||||||
using osu.Game.Rulesets.Judgements;
|
using osu.Game.Rulesets.Judgements;
|
||||||
using osu.Game.Rulesets.Objects;
|
using osu.Game.Rulesets.Objects;
|
||||||
using osu.Game.Rulesets.Objects.Drawables;
|
|
||||||
using osu.Game.Rulesets.Scoring;
|
using osu.Game.Rulesets.Scoring;
|
||||||
using osu.Game.Rulesets.Taiko.Judgements;
|
using osu.Game.Rulesets.Taiko.Judgements;
|
||||||
using osu.Game.Rulesets.Taiko.Objects;
|
using osu.Game.Rulesets.Taiko.Objects;
|
||||||
@ -97,7 +99,7 @@ namespace osu.Game.Rulesets.Taiko.Tests
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 6:
|
case 6:
|
||||||
PlayfieldContainer.Delay(delay).ResizeTo(new Vector2(1, TaikoPlayfield.DEFAULT_HEIGHT), 500);
|
PlayfieldContainer.Delay(delay).ResizeTo(new Vector2(1, DEFAULT_PLAYFIELD_CONTAINER_HEIGHT), 500);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -106,13 +108,8 @@ namespace osu.Game.Rulesets.Taiko.Tests
|
|||||||
{
|
{
|
||||||
HitResult hitResult = RNG.Next(2) == 0 ? HitResult.Ok : HitResult.Great;
|
HitResult hitResult = RNG.Next(2) == 0 ? HitResult.Ok : HitResult.Great;
|
||||||
|
|
||||||
var cpi = new ControlPointInfo();
|
|
||||||
cpi.Add(0, new EffectControlPoint { KiaiMode = kiai });
|
|
||||||
|
|
||||||
Hit hit = new Hit();
|
Hit hit = new Hit();
|
||||||
hit.ApplyDefaults(cpi, new BeatmapDifficulty());
|
var h = new DrawableTestHit(hit, kiai: kiai) { X = RNG.NextSingle(hitResult == HitResult.Ok ? -0.1f : -0.05f, hitResult == HitResult.Ok ? 0.1f : 0.05f) };
|
||||||
|
|
||||||
var h = new DrawableTestHit(hit) { X = RNG.NextSingle(hitResult == HitResult.Ok ? -0.1f : -0.05f, hitResult == HitResult.Ok ? 0.1f : 0.05f) };
|
|
||||||
|
|
||||||
DrawableRuleset.Playfield.Add(h);
|
DrawableRuleset.Playfield.Add(h);
|
||||||
|
|
||||||
@ -123,25 +120,27 @@ namespace osu.Game.Rulesets.Taiko.Tests
|
|||||||
{
|
{
|
||||||
HitResult hitResult = RNG.Next(2) == 0 ? HitResult.Ok : HitResult.Great;
|
HitResult hitResult = RNG.Next(2) == 0 ? HitResult.Ok : HitResult.Great;
|
||||||
|
|
||||||
var cpi = new ControlPointInfo();
|
Hit hit = new Hit
|
||||||
cpi.Add(0, new EffectControlPoint { KiaiMode = kiai });
|
{
|
||||||
|
IsStrong = true,
|
||||||
Hit hit = new Hit();
|
Samples = createSamples(strong: true)
|
||||||
hit.ApplyDefaults(cpi, new BeatmapDifficulty());
|
};
|
||||||
|
var h = new DrawableTestHit(hit, kiai: kiai) { X = RNG.NextSingle(hitResult == HitResult.Ok ? -0.1f : -0.05f, hitResult == HitResult.Ok ? 0.1f : 0.05f) };
|
||||||
var h = new DrawableTestHit(hit) { X = RNG.NextSingle(hitResult == HitResult.Ok ? -0.1f : -0.05f, hitResult == HitResult.Ok ? 0.1f : 0.05f) };
|
|
||||||
|
|
||||||
DrawableRuleset.Playfield.Add(h);
|
DrawableRuleset.Playfield.Add(h);
|
||||||
|
|
||||||
((TaikoPlayfield)DrawableRuleset.Playfield).OnNewResult(h, new JudgementResult(new HitObject(), new TaikoJudgement()) { Type = hitResult });
|
((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 });
|
((TaikoPlayfield)DrawableRuleset.Playfield).OnNewResult(h.NestedHitObjects.Single(), new JudgementResult(new HitObject(), new TaikoStrongJudgement()) { Type = HitResult.Great });
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addMissJudgement()
|
private void addMissJudgement()
|
||||||
{
|
{
|
||||||
DrawableTestHit h;
|
DrawableTestHit h;
|
||||||
DrawableRuleset.Playfield.Add(h = new DrawableTestHit(new Hit(), HitResult.Miss));
|
DrawableRuleset.Playfield.Add(h = new DrawableTestHit(new Hit { StartTime = DrawableRuleset.Playfield.Time.Current }, HitResult.Miss)
|
||||||
((TaikoPlayfield)DrawableRuleset.Playfield).OnNewResult(h, new JudgementResult(new HitObject(), new TaikoJudgement()) { Type = HitResult.Miss });
|
{
|
||||||
|
Alpha = 0
|
||||||
|
});
|
||||||
|
((TaikoPlayfield)DrawableRuleset.Playfield).OnNewResult(h, new JudgementResult(h.HitObject, new TaikoJudgement()) { Type = HitResult.Miss });
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addBarLine(bool major, double delay = scroll_time)
|
private void addBarLine(bool major, double delay = scroll_time)
|
||||||
@ -173,6 +172,7 @@ namespace osu.Game.Rulesets.Taiko.Tests
|
|||||||
{
|
{
|
||||||
StartTime = DrawableRuleset.Playfield.Time.Current + scroll_time,
|
StartTime = DrawableRuleset.Playfield.Time.Current + scroll_time,
|
||||||
IsStrong = strong,
|
IsStrong = strong,
|
||||||
|
Samples = createSamples(strong: strong),
|
||||||
Duration = duration,
|
Duration = duration,
|
||||||
TickRate = 8,
|
TickRate = 8,
|
||||||
};
|
};
|
||||||
@ -190,7 +190,8 @@ namespace osu.Game.Rulesets.Taiko.Tests
|
|||||||
Hit h = new Hit
|
Hit h = new Hit
|
||||||
{
|
{
|
||||||
StartTime = DrawableRuleset.Playfield.Time.Current + scroll_time,
|
StartTime = DrawableRuleset.Playfield.Time.Current + scroll_time,
|
||||||
IsStrong = strong
|
IsStrong = strong,
|
||||||
|
Samples = createSamples(HitType.Centre, strong)
|
||||||
};
|
};
|
||||||
|
|
||||||
h.ApplyDefaults(new ControlPointInfo(), new BeatmapDifficulty());
|
h.ApplyDefaults(new ControlPointInfo(), new BeatmapDifficulty());
|
||||||
@ -203,7 +204,8 @@ namespace osu.Game.Rulesets.Taiko.Tests
|
|||||||
Hit h = new Hit
|
Hit h = new Hit
|
||||||
{
|
{
|
||||||
StartTime = DrawableRuleset.Playfield.Time.Current + scroll_time,
|
StartTime = DrawableRuleset.Playfield.Time.Current + scroll_time,
|
||||||
IsStrong = strong
|
IsStrong = strong,
|
||||||
|
Samples = createSamples(HitType.Rim, strong)
|
||||||
};
|
};
|
||||||
|
|
||||||
h.ApplyDefaults(new ControlPointInfo(), new BeatmapDifficulty());
|
h.ApplyDefaults(new ControlPointInfo(), new BeatmapDifficulty());
|
||||||
@ -211,14 +213,18 @@ namespace osu.Game.Rulesets.Taiko.Tests
|
|||||||
DrawableRuleset.Playfield.Add(new DrawableHit(h));
|
DrawableRuleset.Playfield.Add(new DrawableHit(h));
|
||||||
}
|
}
|
||||||
|
|
||||||
private class TestStrongNestedHit : DrawableStrongNestedHit
|
// 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)
|
||||||
{
|
{
|
||||||
public TestStrongNestedHit(DrawableHitObject mainObject)
|
var samples = new List<HitSampleInfo>();
|
||||||
: base(new StrongHitObject { StartTime = mainObject.HitObject.StartTime }, mainObject)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public override bool OnPressed(TaikoAction action) => false;
|
if (hitType == HitType.Rim)
|
||||||
|
samples.Add(new HitSampleInfo(HitSampleInfo.HIT_CLAP));
|
||||||
|
|
||||||
|
if (strong)
|
||||||
|
samples.Add(new HitSampleInfo(HitSampleInfo.HIT_FINISH));
|
||||||
|
|
||||||
|
return samples;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user