From cfcb0c1c6eec4d3ba8d01bd0943dd32745a0dc07 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 15 Sep 2017 21:26:36 +0900 Subject: [PATCH] Add (incorrectly) exploding fruit --- osu.Game.Rulesets.Catch/UI/CatcherArea.cs | 41 ++++++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) diff --git a/osu.Game.Rulesets.Catch/UI/CatcherArea.cs b/osu.Game.Rulesets.Catch/UI/CatcherArea.cs index f6563c4670..5a1a1dddc4 100644 --- a/osu.Game.Rulesets.Catch/UI/CatcherArea.cs +++ b/osu.Game.Rulesets.Catch/UI/CatcherArea.cs @@ -20,6 +20,7 @@ namespace osu.Game.Rulesets.Catch.UI public class CatcherArea : Container { private Catcher catcher; + private Container explodingFruitContainer; public void Add(DrawableHitObject fruit, Vector2 screenPosition) => catcher.AddToStack(fruit, screenPosition); @@ -30,9 +31,14 @@ namespace osu.Game.Rulesets.Catch.UI { Children = new Drawable[] { + explodingFruitContainer = new Container + { + RelativeSizeAxes = Axes.Both, + }, catcher = new Catcher { RelativePositionAxes = Axes.Both, + ExplodingFruitTarget = explodingFruitContainer, Anchor = Anchor.TopLeft, Origin = Anchor.TopCentre, X = 0.5f, @@ -63,6 +69,8 @@ namespace osu.Game.Rulesets.Catch.UI private bool dashing; + public Container ExplodingFruitTarget; + protected bool Dashing { get { return dashing; } @@ -168,13 +176,44 @@ namespace osu.Game.Rulesets.Catch.UI float distance = fruit.DrawSize.X / 2 * fruit.Scale.X; - while (Children.OfType().Any(f => Vector2Extensions.DistanceSquared(f.Position, fruit.Position) < distance * distance)) + while (Children.OfType().Any(f => f.LifetimeEnd == double.PositiveInfinity && Vector2Extensions.DistanceSquared(f.Position, fruit.Position) < distance * distance)) { fruit.X += RNG.Next(-5, 5); fruit.Y -= RNG.Next(0, 5); } Add(fruit); + + if (((CatchBaseHit)fruit.HitObject).LastInCombo) + explode(); + } + + private void explode() + { + foreach (var existingFruit in Children.OfType().ToArray()) + { + var originalX = existingFruit.X * Scale.X; + + if (ExplodingFruitTarget != null) + { + existingFruit.Anchor = Anchor.TopLeft; + existingFruit.Position = ToSpaceOfOtherDrawable(existingFruit.DrawPosition, ExplodingFruitTarget); + + Remove(existingFruit); + + ExplodingFruitTarget.Add(existingFruit); + } + + existingFruit + .MoveToY(existingFruit.Y - 50, 250, Easing.OutSine) + .Then() + .MoveToY(existingFruit.Y + 50, 500, Easing.InSine); + + existingFruit.MoveToX(existingFruit.X + originalX * 6, 1000); + existingFruit.FadeOut(750); + + existingFruit.Expire(); + } } } }