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;
|
2020-04-27 07:40:57 +08:00
|
|
|
using osu.Framework.Bindables;
|
2020-04-24 12:59:05 +08:00
|
|
|
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.Objects.Drawables;
|
|
|
|
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),
|
|
|
|
}).ToList();
|
|
|
|
|
|
|
|
[Cached(typeof(IScrollingInfo))]
|
|
|
|
private ScrollingTestContainer.TestScrollingInfo info = new ScrollingTestContainer.TestScrollingInfo
|
|
|
|
{
|
|
|
|
Direction = { Value = ScrollingDirection.Left },
|
|
|
|
TimeRange = { Value = 5000 },
|
|
|
|
};
|
|
|
|
|
2020-04-28 05:17:19 +08:00
|
|
|
private Bindable<WorkingBeatmap> workingBeatmap;
|
2020-04-27 07:40:57 +08:00
|
|
|
|
2020-04-29 05:22:50 +08:00
|
|
|
private IEnumerable<TestDrawableTaikoMascot> mascots => this.ChildrenOfType<TestDrawableTaikoMascot>();
|
|
|
|
private IEnumerable<TaikoPlayfield> playfields => this.ChildrenOfType<TaikoPlayfield>();
|
2020-04-24 12:59:05 +08:00
|
|
|
|
2020-04-28 05:17:19 +08:00
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
private void load(Bindable<WorkingBeatmap> beatmap)
|
|
|
|
{
|
|
|
|
workingBeatmap = beatmap;
|
|
|
|
}
|
|
|
|
|
2020-04-24 12:59:05 +08:00
|
|
|
[Test]
|
|
|
|
public void TestStateTextures()
|
|
|
|
{
|
2020-04-27 07:40:57 +08:00
|
|
|
AddStep("Set beatmap", () => setBeatmap());
|
2020-04-24 12:59:05 +08:00
|
|
|
|
2020-04-27 07:40:57 +08:00
|
|
|
AddStep("Create mascot (idle)", () =>
|
2020-04-24 12:59:05 +08:00
|
|
|
{
|
2020-04-29 05:22:50 +08:00
|
|
|
SetContents(() => new TestDrawableTaikoMascot());
|
2020-04-24 12:59:05 +08:00
|
|
|
});
|
|
|
|
|
|
|
|
AddStep("Clear state", () => setState(TaikoMascotAnimationState.Clear));
|
|
|
|
|
|
|
|
AddStep("Kiai state", () => setState(TaikoMascotAnimationState.Kiai));
|
|
|
|
|
|
|
|
AddStep("Fail state", () => setState(TaikoMascotAnimationState.Fail));
|
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void TestPlayfield()
|
|
|
|
{
|
2020-04-27 07:40:57 +08:00
|
|
|
AddStep("Set beatmap", () => setBeatmap());
|
|
|
|
|
|
|
|
AddStep("Create 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:22:50 +08:00
|
|
|
return new DrawableTaikoRuleset(ruleset, workingBeatmap.Value.GetPlayableBeatmap(ruleset.RulesetInfo));
|
2020-04-24 12:59:05 +08:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2020-04-27 07:40:57 +08:00
|
|
|
AddStep("Create hit (miss)", () =>
|
2020-04-24 12:59:05 +08:00
|
|
|
{
|
|
|
|
foreach (var playfield in playfields)
|
2020-04-27 07:40:57 +08:00
|
|
|
addJudgement(playfield, HitResult.Miss);
|
2020-04-24 12:59:05 +08:00
|
|
|
});
|
|
|
|
|
2020-04-27 07:40:57 +08:00
|
|
|
AddUntilStep("Wait for fail state", () => mascots.Where(d => d != null).All(d => d.State == TaikoMascotAnimationState.Fail));
|
|
|
|
|
|
|
|
AddStep("Create hit (great)", () =>
|
2020-04-24 12:59:05 +08:00
|
|
|
{
|
|
|
|
foreach (var playfield in playfields)
|
2020-04-27 07:40:57 +08:00
|
|
|
addJudgement(playfield, HitResult.Great);
|
|
|
|
});
|
|
|
|
|
|
|
|
AddUntilStep("Wait for idle state", () => mascots.Where(d => d != null).All(d => d.State == TaikoMascotAnimationState.Idle));
|
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void TestKiai()
|
|
|
|
{
|
|
|
|
AddStep("Set beatmap", () => setBeatmap(true));
|
|
|
|
|
2020-04-28 05:17:19 +08:00
|
|
|
AddUntilStep("Wait for beatmap to be loaded", () => workingBeatmap.Value.Track.IsLoaded);
|
2020-04-27 07:40:57 +08:00
|
|
|
|
|
|
|
AddStep("Create kiai ruleset", () =>
|
|
|
|
{
|
2020-04-28 05:17:19 +08:00
|
|
|
workingBeatmap.Value.Track.Start();
|
2020-04-27 07:40:57 +08:00
|
|
|
|
|
|
|
SetContents(() =>
|
|
|
|
{
|
|
|
|
var ruleset = new TaikoRuleset();
|
2020-04-29 05:22:50 +08:00
|
|
|
return new DrawableTaikoRuleset(ruleset, workingBeatmap.Value.GetPlayableBeatmap(ruleset.RulesetInfo));
|
2020-04-27 07:40:57 +08:00
|
|
|
});
|
2020-04-24 12:59:05 +08:00
|
|
|
});
|
|
|
|
|
2020-04-27 07:40:57 +08:00
|
|
|
AddUntilStep("Wait for fail state", () => mascots.Where(d => d != null).All(d => d.State == TaikoMascotAnimationState.Fail));
|
2020-04-24 12:59:05 +08:00
|
|
|
|
|
|
|
AddStep("Create hit (great)", () =>
|
|
|
|
{
|
|
|
|
foreach (var playfield in playfields)
|
|
|
|
addJudgement(playfield, HitResult.Great);
|
|
|
|
});
|
|
|
|
|
2020-04-27 07:40:57 +08:00
|
|
|
AddUntilStep("Wait for kiai state", () => mascots.Where(d => d != null).All(d => d.State == TaikoMascotAnimationState.Kiai));
|
|
|
|
}
|
|
|
|
|
|
|
|
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-28 05:17:19 +08:00
|
|
|
workingBeatmap.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 setState(TaikoMascotAnimationState state)
|
|
|
|
{
|
|
|
|
foreach (var mascot in mascots)
|
|
|
|
mascot?.ShowState(state);
|
|
|
|
}
|
|
|
|
|
2020-04-24 12:59:05 +08:00
|
|
|
private void addJudgement(TaikoPlayfield playfield, HitResult result)
|
|
|
|
{
|
2020-04-27 19:12:31 +08:00
|
|
|
playfield.OnNewResult(new DrawableHit(new Hit()), new JudgementResult(new HitObject(), new TaikoJudgement()) { Type = result });
|
2020-04-24 12:59:05 +08:00
|
|
|
}
|
2020-04-27 07:40:57 +08:00
|
|
|
|
|
|
|
private class TestDrawableTaikoMascot : DrawableTaikoMascot
|
|
|
|
{
|
|
|
|
public TestDrawableTaikoMascot(TaikoMascotAnimationState startingState = TaikoMascotAnimationState.Idle)
|
|
|
|
: base(startingState)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
protected override TaikoMascotAnimationState GetFinalAnimationState(EffectControlPoint effectPoint, TaikoMascotAnimationState playfieldState)
|
|
|
|
{
|
|
|
|
return State;
|
|
|
|
}
|
|
|
|
}
|
2020-04-24 12:59:05 +08:00
|
|
|
}
|
|
|
|
}
|