1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 10:18:22 +08:00
osu-lazer/osu.Game.Rulesets.Taiko.Tests/Skinning/TestSceneDrawableTaikoMascot.cs

138 lines
5.2 KiB
C#
Raw Normal View History

// 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.
using System;
using System.Collections.Generic;
using System.Linq;
using NUnit.Framework;
using osu.Framework.Allocation;
using osu.Framework.Testing;
2020-04-27 07:40:57 +08:00
using osu.Game.Beatmaps;
using osu.Game.Beatmaps.ControlPoints;
using osu.Game.Rulesets.Judgements;
using osu.Game.Rulesets.Objects;
using osu.Game.Rulesets.Scoring;
using osu.Game.Rulesets.Taiko.Judgements;
using osu.Game.Rulesets.Taiko.Objects;
using osu.Game.Rulesets.Taiko.UI;
using osu.Game.Rulesets.UI.Scrolling;
using osu.Game.Tests.Visual;
namespace osu.Game.Rulesets.Taiko.Tests.Skinning
{
[TestFixture]
public class TestSceneDrawableTaikoMascot : TaikoSkinnableTestScene
{
public override IReadOnlyList<Type> RequiredTypes => base.RequiredTypes.Concat(new[]
{
typeof(DrawableTaikoMascot),
typeof(TaikoMascotAnimation)
}).ToList();
[Cached(typeof(IScrollingInfo))]
private ScrollingTestContainer.TestScrollingInfo info = new ScrollingTestContainer.TestScrollingInfo
{
Direction = { Value = ScrollingDirection.Left },
TimeRange = { Value = 5000 },
};
private IEnumerable<DrawableTaikoMascot> mascots => this.ChildrenOfType<DrawableTaikoMascot>();
2020-04-29 05:22:50 +08:00
private IEnumerable<TaikoPlayfield> playfields => this.ChildrenOfType<TaikoPlayfield>();
2020-04-28 05:17:19 +08:00
[Test]
public void TestStateAnimations()
{
AddStep("set beatmap", () => setBeatmap());
AddStep("clear state", () => SetContents(() => new TaikoMascotAnimation(TaikoMascotAnimationState.Clear)));
AddStep("idle state", () => SetContents(() => new TaikoMascotAnimation(TaikoMascotAnimationState.Idle)));
AddStep("kiai state", () => SetContents(() => new TaikoMascotAnimation(TaikoMascotAnimationState.Kiai)));
AddStep("fail state", () => SetContents(() => new TaikoMascotAnimation(TaikoMascotAnimationState.Fail)));
}
[Test]
public void TestPlayfield()
{
AddStep("set beatmap", () => setBeatmap());
2020-04-27 07:40:57 +08:00
AddStep("create drawable ruleset", () =>
{
SetContents(() =>
{
2020-04-27 07:40:57 +08:00
var ruleset = new TaikoRuleset();
2020-04-29 05:24:21 +08:00
return new DrawableTaikoRuleset(ruleset, Beatmap.Value.GetPlayableBeatmap(ruleset.RulesetInfo));
});
});
AddStep("new judgement (miss)", () => addJudgement(HitResult.Miss));
AddUntilStep("wait for fail state", () => assertState(TaikoMascotAnimationState.Fail));
2020-04-27 07:40:57 +08:00
AddStep("new judgement (great)", () => addJudgement(HitResult.Great));
AddUntilStep("wait for idle state", () => assertState(TaikoMascotAnimationState.Idle));
2020-04-27 07:40:57 +08:00
}
[Test]
public void TestKiai()
{
AddStep("set beatmap", () => setBeatmap(true));
2020-04-27 07:40:57 +08:00
AddUntilStep("wait for beatmap to be loaded", () => Beatmap.Value.Track.IsLoaded);
2020-04-27 07:40:57 +08:00
AddStep("create drawable ruleset", () =>
2020-04-27 07:40:57 +08:00
{
2020-04-29 05:24:21 +08:00
Beatmap.Value.Track.Start();
2020-04-27 07:40:57 +08:00
SetContents(() =>
{
var ruleset = new TaikoRuleset();
2020-04-29 05:24:21 +08:00
return new DrawableTaikoRuleset(ruleset, Beatmap.Value.GetPlayableBeatmap(ruleset.RulesetInfo));
2020-04-27 07:40:57 +08:00
});
});
AddUntilStep("wait for fail state", () => assertState(TaikoMascotAnimationState.Fail));
AddStep("new judgement (great)", () => addJudgement(HitResult.Great));
AddUntilStep("wait for kiai state", () => assertState(TaikoMascotAnimationState.Kiai));
2020-04-27 07:40:57 +08:00
}
private void setBeatmap(bool kiai = false)
{
var controlPointInfo = new ControlPointInfo();
controlPointInfo.Add(0, new TimingControlPoint { BeatLength = 90 });
if (kiai)
controlPointInfo.Add(0, new EffectControlPoint { KiaiMode = true });
2020-04-29 05:24:21 +08:00
Beatmap.Value = CreateWorkingBeatmap(new Beatmap
2020-04-27 07:40:57 +08:00
{
HitObjects = new List<HitObject> { new Hit { Type = HitType.Centre } },
BeatmapInfo = new BeatmapInfo
{
BaseDifficulty = new BeatmapDifficulty(),
Metadata = new BeatmapMetadata
{
Artist = @"Unknown",
Title = @"Sample Beatmap",
AuthorString = @"Craftplacer",
},
Ruleset = new TaikoRuleset().RulesetInfo
},
ControlPointInfo = controlPointInfo
});
}
private void addJudgement(HitResult result)
2020-04-27 07:40:57 +08:00
{
foreach (var playfield in playfields)
{
var hit = new DrawableTestHit(new Hit(), result);
Add(hit);
2020-04-27 07:40:57 +08:00
playfield.OnNewResult(hit, new JudgementResult(hit.HitObject, new TaikoJudgement()) { Type = result });
2020-04-27 07:40:57 +08:00
}
}
private bool assertState(TaikoMascotAnimationState state) => mascots.All(d => d.State.Value == state);
}
}