2020-04-24 12:59:05 +08: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.
|
|
|
|
|
|
|
|
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;
|
2020-04-24 12:59:05 +08:00
|
|
|
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),
|
2020-04-30 03:27:02 +08:00
|
|
|
typeof(TaikoMascotAnimation)
|
2020-04-24 12:59:05 +08:00
|
|
|
}).ToList();
|
|
|
|
|
|
|
|
[Cached(typeof(IScrollingInfo))]
|
|
|
|
private ScrollingTestContainer.TestScrollingInfo info = new ScrollingTestContainer.TestScrollingInfo
|
|
|
|
{
|
|
|
|
Direction = { Value = ScrollingDirection.Left },
|
|
|
|
TimeRange = { Value = 5000 },
|
|
|
|
};
|
|
|
|
|
2020-04-30 03:27:02 +08:00
|
|
|
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
|
|
|
|
2020-04-24 12:59:05 +08:00
|
|
|
[Test]
|
2020-04-30 03:27:02 +08:00
|
|
|
public void TestStateAnimations()
|
2020-04-24 12:59:05 +08:00
|
|
|
{
|
2020-04-30 02:28:46 +08:00
|
|
|
AddStep("set beatmap", () => setBeatmap());
|
2020-04-24 12:59:05 +08:00
|
|
|
|
2020-04-30 03:27:02 +08:00
|
|
|
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)));
|
2020-04-24 12:59:05 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void TestPlayfield()
|
|
|
|
{
|
2020-04-30 02:28:46 +08:00
|
|
|
AddStep("set beatmap", () => setBeatmap());
|
2020-04-27 07:40:57 +08:00
|
|
|
|
2020-04-30 02:28:46 +08:00
|
|
|
AddStep("create drawable ruleset", () =>
|
2020-04-24 12:59:05 +08:00
|
|
|
{
|
|
|
|
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));
|
2020-04-24 12:59:05 +08:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2020-04-30 02:28:46 +08:00
|
|
|
AddStep("new judgement (miss)", () => addJudgement(HitResult.Miss));
|
|
|
|
AddUntilStep("wait for fail state", () => assertState(TaikoMascotAnimationState.Fail));
|
2020-04-27 07:40:57 +08:00
|
|
|
|
2020-04-30 02:28:46 +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()
|
|
|
|
{
|
2020-04-30 02:28:46 +08:00
|
|
|
AddStep("set beatmap", () => setBeatmap(true));
|
2020-04-27 07:40:57 +08:00
|
|
|
|
2020-04-30 02:28:46 +08:00
|
|
|
AddUntilStep("wait for beatmap to be loaded", () => Beatmap.Value.Track.IsLoaded);
|
2020-04-27 07:40:57 +08:00
|
|
|
|
2020-04-30 02:28:46 +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
|
|
|
});
|
2020-04-24 12:59:05 +08:00
|
|
|
});
|
|
|
|
|
2020-04-30 02:28:46 +08:00
|
|
|
AddUntilStep("wait for fail state", () => assertState(TaikoMascotAnimationState.Fail));
|
2020-04-24 12:59:05 +08:00
|
|
|
|
2020-04-30 02:28:46 +08:00
|
|
|
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
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2020-04-29 05:51:34 +08:00
|
|
|
private void addJudgement(HitResult result)
|
2020-04-27 07:40:57 +08:00
|
|
|
{
|
|
|
|
foreach (var playfield in playfields)
|
|
|
|
{
|
2020-04-29 05:51:34 +08:00
|
|
|
var hit = new DrawableTestHit(new Hit(), result);
|
|
|
|
Add(hit);
|
2020-04-27 07:40:57 +08:00
|
|
|
|
2020-04-29 05:51:34 +08:00
|
|
|
playfield.OnNewResult(hit, new JudgementResult(hit.HitObject, new TaikoJudgement()) { Type = result });
|
2020-04-27 07:40:57 +08:00
|
|
|
}
|
2020-04-24 12:59:05 +08:00
|
|
|
}
|
|
|
|
|
2020-04-30 02:28:46 +08:00
|
|
|
private bool assertState(TaikoMascotAnimationState state) => mascots.All(d => d.State.Value == state);
|
2020-04-24 12:59:05 +08:00
|
|
|
}
|
|
|
|
}
|