1
0
mirror of https://github.com/ppy/osu.git synced 2024-10-01 02:17:25 +08:00
osu-lazer/osu.Game.Rulesets.Catch.Tests/TestSceneFruitObjects.cs

70 lines
2.6 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 System;
using NUnit.Framework;
using osu.Framework.Graphics;
using osu.Game.Rulesets.Catch.Objects;
using osu.Game.Rulesets.Catch.Objects.Drawables;
2018-11-20 15:51:59 +08:00
using osuTK;
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();
foreach (FruitVisualRepresentation rep in Enum.GetValues(typeof(FruitVisualRepresentation)))
2020-11-17 22:40:30 +08:00
AddStep($"show {rep}", () => SetContents(() => createDrawableFruit(rep)));
2020-08-20 22:16:37 +08:00
AddStep("show droplet", () => SetContents(() => createDrawableDroplet()));
AddStep("show tiny droplet", () => SetContents(createDrawableTinyDroplet));
foreach (FruitVisualRepresentation rep in Enum.GetValues(typeof(FruitVisualRepresentation)))
2020-11-17 22:40:30 +08:00
AddStep($"show hyperdash {rep}", () => SetContents(() => createDrawableFruit(rep, true)));
2020-08-20 22:16:37 +08:00
AddStep("show hyperdash droplet", () => SetContents(() => createDrawableDroplet(true)));
}
2020-11-17 22:40:30 +08:00
private Drawable createDrawableFruit(FruitVisualRepresentation rep, bool hyperdash = false) =>
setProperties(new DrawableFruit(new TestCatchFruit(rep)), hyperdash);
2020-11-17 17:13:32 +08:00
2020-11-17 22:40:30 +08:00
private Drawable createDrawableDroplet(bool hyperdash = false) => setProperties(new DrawableDroplet(new Droplet()), hyperdash);
2020-11-17 22:40:30 +08:00
private Drawable createDrawableTinyDroplet() => setProperties(new DrawableTinyDroplet(new TinyDroplet()));
2018-04-13 17:19:50 +08:00
2020-11-17 22:40:30 +08:00
private DrawableCatchHitObject setProperties(DrawableCatchHitObject d, bool hyperdash = false)
2020-11-17 17:13:32 +08:00
{
2020-11-17 22:40:30 +08:00
var hitObject = d.HitObject;
hitObject.StartTime = 1000000000000;
hitObject.Scale = 1.5f;
2020-11-17 17:13:32 +08:00
2020-11-17 22:40:30 +08:00
if (hyperdash)
((PalpableCatchHitObject)hitObject).HyperDashTarget = new Banana();
2018-04-13 17:19:50 +08:00
2020-11-17 22:40:30 +08:00
d.Anchor = Anchor.Centre;
d.RelativePositionAxes = Axes.None;
d.Position = Vector2.Zero;
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
};
2020-11-17 22:40:30 +08:00
return d;
2020-11-17 17:13:32 +08:00
}
public class TestCatchFruit : Fruit
{
public TestCatchFruit(FruitVisualRepresentation rep)
{
VisualRepresentation = rep;
}
public override FruitVisualRepresentation VisualRepresentation { get; }
}
2018-04-13 17:19:50 +08:00
}
}