mirror of
https://github.com/osukey/osukey.git
synced 2025-05-23 06:27:24 +09:00
Put caught fruit in their own container to reduce casting
This commit is contained in:
parent
cfcb0c1c6e
commit
e52a4fe72c
@ -11,7 +11,6 @@ using osu.Framework.Graphics.Textures;
|
|||||||
using osu.Framework.Input.Bindings;
|
using osu.Framework.Input.Bindings;
|
||||||
using osu.Framework.MathUtils;
|
using osu.Framework.MathUtils;
|
||||||
using osu.Game.Rulesets.Catch.Objects;
|
using osu.Game.Rulesets.Catch.Objects;
|
||||||
using osu.Game.Rulesets.Catch.Objects.Drawable;
|
|
||||||
using osu.Game.Rulesets.Objects.Drawables;
|
using osu.Game.Rulesets.Objects.Drawables;
|
||||||
using OpenTK;
|
using OpenTK;
|
||||||
|
|
||||||
@ -39,7 +38,6 @@ namespace osu.Game.Rulesets.Catch.UI
|
|||||||
{
|
{
|
||||||
RelativePositionAxes = Axes.Both,
|
RelativePositionAxes = Axes.Both,
|
||||||
ExplodingFruitTarget = explodingFruitContainer,
|
ExplodingFruitTarget = explodingFruitContainer,
|
||||||
Anchor = Anchor.TopLeft,
|
|
||||||
Origin = Anchor.TopCentre,
|
Origin = Anchor.TopCentre,
|
||||||
X = 0.5f,
|
X = 0.5f,
|
||||||
}
|
}
|
||||||
@ -57,12 +55,22 @@ namespace osu.Game.Rulesets.Catch.UI
|
|||||||
{
|
{
|
||||||
private Texture texture;
|
private Texture texture;
|
||||||
|
|
||||||
|
private Container<DrawableHitObject> caughtFruit;
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load(TextureStore textures)
|
private void load(TextureStore textures)
|
||||||
{
|
{
|
||||||
texture = textures.Get(@"Play/Catch/fruit-catcher-idle");
|
texture = textures.Get(@"Play/Catch/fruit-catcher-idle");
|
||||||
|
|
||||||
Child = createCatcherSprite();
|
Children = new Drawable[]
|
||||||
|
{
|
||||||
|
createCatcherSprite(),
|
||||||
|
caughtFruit = new Container<DrawableHitObject>
|
||||||
|
{
|
||||||
|
Anchor = Anchor.TopCentre,
|
||||||
|
Origin = Anchor.BottomCentre,
|
||||||
|
}
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
private int currentDirection;
|
private int currentDirection;
|
||||||
@ -176,13 +184,13 @@ namespace osu.Game.Rulesets.Catch.UI
|
|||||||
|
|
||||||
float distance = fruit.DrawSize.X / 2 * fruit.Scale.X;
|
float distance = fruit.DrawSize.X / 2 * fruit.Scale.X;
|
||||||
|
|
||||||
while (Children.OfType<DrawableFruit>().Any(f => f.LifetimeEnd == double.PositiveInfinity && Vector2Extensions.DistanceSquared(f.Position, fruit.Position) < distance * distance))
|
while (caughtFruit.Any(f => f.LifetimeEnd == double.PositiveInfinity && Vector2Extensions.DistanceSquared(f.Position, fruit.Position) < distance * distance))
|
||||||
{
|
{
|
||||||
fruit.X += RNG.Next(-5, 5);
|
fruit.X += RNG.Next(-5, 5);
|
||||||
fruit.Y -= RNG.Next(0, 5);
|
fruit.Y -= RNG.Next(0, 5);
|
||||||
}
|
}
|
||||||
|
|
||||||
Add(fruit);
|
caughtFruit.Add(fruit);
|
||||||
|
|
||||||
if (((CatchBaseHit)fruit.HitObject).LastInCombo)
|
if (((CatchBaseHit)fruit.HitObject).LastInCombo)
|
||||||
explode();
|
explode();
|
||||||
@ -190,29 +198,31 @@ namespace osu.Game.Rulesets.Catch.UI
|
|||||||
|
|
||||||
private void explode()
|
private void explode()
|
||||||
{
|
{
|
||||||
foreach (var existingFruit in Children.OfType<DrawableFruit>().ToArray())
|
var fruit = caughtFruit.ToArray();
|
||||||
|
caughtFruit.Clear(false);
|
||||||
|
|
||||||
|
foreach (var f in fruit)
|
||||||
{
|
{
|
||||||
var originalX = existingFruit.X * Scale.X;
|
var originalX = f.X * Scale.X;
|
||||||
|
|
||||||
if (ExplodingFruitTarget != null)
|
if (ExplodingFruitTarget != null)
|
||||||
{
|
{
|
||||||
existingFruit.Anchor = Anchor.TopLeft;
|
f.Anchor = Anchor.TopLeft;
|
||||||
existingFruit.Position = ToSpaceOfOtherDrawable(existingFruit.DrawPosition, ExplodingFruitTarget);
|
f.Position = ToSpaceOfOtherDrawable(f.DrawPosition, ExplodingFruitTarget);
|
||||||
|
|
||||||
Remove(existingFruit);
|
caughtFruit.Remove(f);
|
||||||
|
|
||||||
ExplodingFruitTarget.Add(existingFruit);
|
ExplodingFruitTarget.Add(f);
|
||||||
}
|
}
|
||||||
|
|
||||||
existingFruit
|
f.MoveToY(f.Y - 50, 250, Easing.OutSine)
|
||||||
.MoveToY(existingFruit.Y - 50, 250, Easing.OutSine)
|
.Then()
|
||||||
.Then()
|
.MoveToY(f.Y + 50, 500, Easing.InSine);
|
||||||
.MoveToY(existingFruit.Y + 50, 500, Easing.InSine);
|
|
||||||
|
|
||||||
existingFruit.MoveToX(existingFruit.X + originalX * 6, 1000);
|
f.MoveToX(f.X + originalX * 6, 1000);
|
||||||
existingFruit.FadeOut(750);
|
f.FadeOut(750);
|
||||||
|
|
||||||
existingFruit.Expire();
|
f.Expire();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user