1
0
mirror of https://github.com/ppy/osu.git synced 2025-02-05 02:43:16 +08:00

Merge pull request #10881 from ekrctb/fix-TestSceneFruitObjects

Fix TestSceneFruitObjects not displaying anything
This commit is contained in:
Dan Balasescu 2020-11-18 00:13:26 +09:00 committed by GitHub
commit 851c7d524f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -18,71 +18,42 @@ namespace osu.Game.Rulesets.Catch.Tests
base.LoadComplete(); base.LoadComplete();
foreach (FruitVisualRepresentation rep in Enum.GetValues(typeof(FruitVisualRepresentation))) foreach (FruitVisualRepresentation rep in Enum.GetValues(typeof(FruitVisualRepresentation)))
AddStep($"show {rep}", () => SetContents(() => createDrawable(rep))); AddStep($"show {rep}", () => SetContents(() => createDrawableFruit(rep)));
AddStep("show droplet", () => SetContents(() => createDrawableDroplet())); AddStep("show droplet", () => SetContents(() => createDrawableDroplet()));
AddStep("show tiny droplet", () => SetContents(createDrawableTinyDroplet)); AddStep("show tiny droplet", () => SetContents(createDrawableTinyDroplet));
foreach (FruitVisualRepresentation rep in Enum.GetValues(typeof(FruitVisualRepresentation))) foreach (FruitVisualRepresentation rep in Enum.GetValues(typeof(FruitVisualRepresentation)))
AddStep($"show hyperdash {rep}", () => SetContents(() => createDrawable(rep, true))); AddStep($"show hyperdash {rep}", () => SetContents(() => createDrawableFruit(rep, true)));
AddStep("show hyperdash droplet", () => SetContents(() => createDrawableDroplet(true))); AddStep("show hyperdash droplet", () => SetContents(() => createDrawableDroplet(true)));
} }
private Drawable createDrawableTinyDroplet() private Drawable createDrawableFruit(FruitVisualRepresentation rep, bool hyperdash = false) =>
{ setProperties(new DrawableFruit(new TestCatchFruit(rep)), hyperdash);
var droplet = new TestCatchTinyDroplet
{
Scale = 1.5f,
};
return new DrawableTinyDroplet(droplet) private Drawable createDrawableDroplet(bool hyperdash = false) => setProperties(new DrawableDroplet(new Droplet()), hyperdash);
{
Anchor = Anchor.Centre,
RelativePositionAxes = Axes.None,
Position = Vector2.Zero,
Alpha = 1,
LifetimeStart = double.NegativeInfinity,
LifetimeEnd = double.PositiveInfinity,
};
}
private Drawable createDrawableDroplet(bool hyperdash = false) private Drawable createDrawableTinyDroplet() => setProperties(new DrawableTinyDroplet(new TinyDroplet()));
{
var droplet = new TestCatchDroplet
{
Scale = 1.5f,
HyperDashTarget = hyperdash ? new Banana() : null
};
return new DrawableDroplet(droplet) private DrawableCatchHitObject setProperties(DrawableCatchHitObject d, bool hyperdash = false)
{ {
Anchor = Anchor.Centre, var hitObject = d.HitObject;
RelativePositionAxes = Axes.None, hitObject.StartTime = 1000000000000;
Position = Vector2.Zero, hitObject.Scale = 1.5f;
Alpha = 1,
LifetimeStart = double.NegativeInfinity,
LifetimeEnd = double.PositiveInfinity,
};
}
private Drawable createDrawable(FruitVisualRepresentation rep, bool hyperdash = false) if (hyperdash)
{ hitObject.HyperDashTarget = new Banana();
Fruit fruit = new TestCatchFruit(rep)
{
Scale = 1.5f,
HyperDashTarget = hyperdash ? new Banana() : null
};
return new DrawableFruit(fruit) d.Anchor = Anchor.Centre;
d.RelativePositionAxes = Axes.None;
d.Position = Vector2.Zero;
d.HitObjectApplied += _ =>
{ {
Anchor = Anchor.Centre, d.LifetimeStart = double.NegativeInfinity;
RelativePositionAxes = Axes.None, d.LifetimeEnd = double.PositiveInfinity;
Position = Vector2.Zero,
Alpha = 1,
LifetimeStart = double.NegativeInfinity,
LifetimeEnd = double.PositiveInfinity,
}; };
return d;
} }
public class TestCatchFruit : Fruit public class TestCatchFruit : Fruit
@ -90,26 +61,9 @@ namespace osu.Game.Rulesets.Catch.Tests
public TestCatchFruit(FruitVisualRepresentation rep) public TestCatchFruit(FruitVisualRepresentation rep)
{ {
VisualRepresentation = rep; VisualRepresentation = rep;
StartTime = 1000000000000;
} }
public override FruitVisualRepresentation VisualRepresentation { get; } public override FruitVisualRepresentation VisualRepresentation { get; }
} }
public class TestCatchDroplet : Droplet
{
public TestCatchDroplet()
{
StartTime = 1000000000000;
}
}
public class TestCatchTinyDroplet : TinyDroplet
{
public TestCatchTinyDroplet()
{
StartTime = 1000000000000;
}
}
} }
} }