1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-14 15:17:27 +08:00
osu-lazer/osu.Game.Rulesets.Catch.Tests/TestSceneFruitObjects.cs

88 lines
3.5 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.
2018-04-13 17:19:50 +08:00
using NUnit.Framework;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Timing;
using osu.Game.Beatmaps;
using osu.Game.Beatmaps.ControlPoints;
2018-04-13 17:19:50 +08:00
using osu.Game.Rulesets.Catch.Objects;
using osu.Game.Rulesets.Catch.Objects.Drawables;
2018-04-13 17:19:50 +08:00
namespace osu.Game.Rulesets.Catch.Tests
{
[TestFixture]
public class TestSceneFruitObjects : CatchSkinnableTestScene
2018-04-13 17:19:50 +08:00
{
protected override void LoadComplete()
2018-04-13 17:19:50 +08:00
{
base.LoadComplete();
AddStep("show pear", () => SetContents(() => createDrawableFruit(0)));
AddStep("show grape", () => SetContents(() => createDrawableFruit(1)));
AddStep("show pineapple / apple", () => SetContents(() => createDrawableFruit(2)));
AddStep("show raspberry / orange", () => SetContents(() => createDrawableFruit(3)));
AddStep("show banana", () => SetContents(createDrawableBanana));
2020-08-20 22:16:37 +08:00
AddStep("show droplet", () => SetContents(() => createDrawableDroplet()));
AddStep("show tiny droplet", () => SetContents(createDrawableTinyDroplet));
AddStep("show hyperdash pear", () => SetContents(() => createDrawableFruit(0, true)));
AddStep("show hyperdash grape", () => SetContents(() => createDrawableFruit(1, true)));
AddStep("show hyperdash pineapple / apple", () => SetContents(() => createDrawableFruit(2, true)));
AddStep("show hyperdash raspberry / orange", () => SetContents(() => createDrawableFruit(3, true)));
2020-08-20 22:16:37 +08:00
AddStep("show hyperdash droplet", () => SetContents(() => createDrawableDroplet(true)));
}
private Drawable createDrawableFruit(int indexInBeatmap, bool hyperdash = false) =>
new TestDrawableCatchHitObjectSpecimen(new DrawableFruit(new Fruit
{
IndexInBeatmap = indexInBeatmap,
HyperDashBindable = { Value = hyperdash }
}));
private Drawable createDrawableBanana() =>
new TestDrawableCatchHitObjectSpecimen(new DrawableBanana(new Banana()));
2020-11-17 17:13:32 +08:00
private Drawable createDrawableDroplet(bool hyperdash = false) =>
new TestDrawableCatchHitObjectSpecimen(new DrawableDroplet(new Droplet
{
HyperDashBindable = { Value = hyperdash }
}));
private Drawable createDrawableTinyDroplet() => new TestDrawableCatchHitObjectSpecimen(new DrawableTinyDroplet(new TinyDroplet()));
}
public class TestDrawableCatchHitObjectSpecimen : CompositeDrawable
{
public readonly ManualClock ManualClock;
2018-04-13 17:19:50 +08:00
public TestDrawableCatchHitObjectSpecimen(DrawableCatchHitObject d)
2020-11-17 17:13:32 +08:00
{
AutoSizeAxes = Axes.Both;
Anchor = Anchor.Centre;
Origin = Anchor.Centre;
ManualClock = new ManualClock();
Clock = new FramedClock(ManualClock);
2020-11-17 22:40:30 +08:00
var hitObject = d.HitObject;
hitObject.ApplyDefaults(new ControlPointInfo(), new BeatmapDifficulty());
2020-11-17 22:40:30 +08:00
hitObject.Scale = 1.5f;
hitObject.StartTime = 500;
2018-04-13 17:19:50 +08:00
2020-11-17 22:40:30 +08:00
d.Anchor = Anchor.Centre;
d.HitObjectApplied += _ =>
2018-04-13 17:19:50 +08:00
{
2020-11-17 22:40:30 +08:00
d.LifetimeStart = double.NegativeInfinity;
d.LifetimeEnd = double.PositiveInfinity;
2018-04-13 17:19:50 +08:00
};
InternalChild = d;
2020-11-17 17:13:32 +08:00
}
2018-04-13 17:19:50 +08:00
}
}