2020-04-27 13:22:32 +00: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 NUnit.Framework;
|
2021-03-14 14:56:34 +00:00
|
|
|
using osu.Framework.Extensions.IEnumerableExtensions;
|
2020-04-27 13:22:32 +00:00
|
|
|
using osu.Framework.Graphics;
|
|
|
|
using osu.Framework.Graphics.Containers;
|
2021-03-14 14:56:34 +00:00
|
|
|
using osu.Framework.Testing;
|
|
|
|
using osu.Game.Rulesets.Judgements;
|
|
|
|
using osu.Game.Rulesets.Objects;
|
2020-04-27 13:22:32 +00:00
|
|
|
using osu.Game.Rulesets.Scoring;
|
|
|
|
using osu.Game.Rulesets.Taiko.Objects;
|
|
|
|
using osu.Game.Rulesets.Taiko.UI;
|
|
|
|
|
|
|
|
namespace osu.Game.Rulesets.Taiko.Tests.Skinning
|
|
|
|
{
|
|
|
|
[TestFixture]
|
|
|
|
public class TestSceneHitExplosion : TaikoSkinnableTestScene
|
|
|
|
{
|
2021-03-14 14:56:34 +00:00
|
|
|
protected override double TimePerAction => 100;
|
|
|
|
|
2020-09-20 16:10:44 +00:00
|
|
|
[Test]
|
|
|
|
public void TestNormalHit()
|
2020-04-27 13:22:32 +00:00
|
|
|
{
|
2021-06-02 07:04:53 +00:00
|
|
|
AddStep("Great", () => SetContents(_ => getContentFor(createHit(HitResult.Great))));
|
|
|
|
AddStep("Ok", () => SetContents(_ => getContentFor(createHit(HitResult.Ok))));
|
|
|
|
AddStep("Miss", () => SetContents(_ => getContentFor(createHit(HitResult.Miss))));
|
2020-04-27 13:22:32 +00:00
|
|
|
}
|
|
|
|
|
2021-03-14 14:56:34 +00:00
|
|
|
[TestCase(HitResult.Great)]
|
|
|
|
[TestCase(HitResult.Ok)]
|
|
|
|
public void TestStrongHit(HitResult type)
|
2020-04-27 13:22:32 +00:00
|
|
|
{
|
2021-06-02 07:04:53 +00:00
|
|
|
AddStep("create hit", () => SetContents(_ => getContentFor(createStrongHit(type))));
|
2021-03-14 14:56:34 +00:00
|
|
|
AddStep("visualise second hit",
|
|
|
|
() => this.ChildrenOfType<HitExplosion>()
|
|
|
|
.ForEach(e => e.VisualiseSecondHit(new JudgementResult(new HitObject { StartTime = Time.Current }, new Judgement()))));
|
2020-09-20 16:10:44 +00:00
|
|
|
}
|
2020-04-27 13:22:32 +00:00
|
|
|
|
2020-09-25 10:25:58 +00:00
|
|
|
private Drawable getContentFor(DrawableTestHit hit)
|
2020-09-20 16:10:44 +00:00
|
|
|
{
|
2020-04-27 13:22:32 +00:00
|
|
|
return new Container
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
Children = new Drawable[]
|
|
|
|
{
|
2020-09-26 15:26:26 +00:00
|
|
|
// the hit needs to be added to hierarchy in order for nested objects to be created correctly.
|
|
|
|
// setting zero alpha is supposed to prevent the test from looking broken.
|
|
|
|
hit.With(h => h.Alpha = 0),
|
2021-03-14 14:51:38 +00:00
|
|
|
new HitExplosion(hit.Type)
|
2020-04-27 13:22:32 +00:00
|
|
|
{
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
Origin = Anchor.Centre,
|
2021-03-14 14:51:38 +00:00
|
|
|
}.With(explosion => explosion.Apply(hit))
|
2020-04-27 13:22:32 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2020-09-25 10:25:58 +00:00
|
|
|
private DrawableTestHit createHit(HitResult type) => new DrawableTestHit(new Hit { StartTime = Time.Current }, type);
|
2020-09-20 16:10:44 +00:00
|
|
|
|
2021-03-14 14:56:34 +00:00
|
|
|
private DrawableTestHit createStrongHit(HitResult type) => new DrawableTestStrongHit(Time.Current, type);
|
2020-04-27 13:22:32 +00:00
|
|
|
}
|
|
|
|
}
|