From f28053b2fcaf1f6ce01c6d5ae42bf304732c0b87 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 4 Jan 2018 18:13:59 +0900 Subject: [PATCH 1/2] Drop fruit when last in combo is not caught Also cleans up judgement handling a bit --- osu.Game.Rulesets.Catch/UI/CatchPlayfield.cs | 15 +---- osu.Game.Rulesets.Catch/UI/CatcherArea.cs | 66 +++++++++++++++----- 2 files changed, 53 insertions(+), 28 deletions(-) diff --git a/osu.Game.Rulesets.Catch/UI/CatchPlayfield.cs b/osu.Game.Rulesets.Catch/UI/CatchPlayfield.cs index 76dbfa77c6..c4458dbe9b 100644 --- a/osu.Game.Rulesets.Catch/UI/CatchPlayfield.cs +++ b/osu.Game.Rulesets.Catch/UI/CatchPlayfield.cs @@ -3,7 +3,6 @@ using osu.Framework.Graphics; using osu.Game.Rulesets.UI; -using OpenTK; using osu.Framework.Graphics.Containers; using osu.Game.Beatmaps; using osu.Game.Rulesets.Catch.Objects; @@ -63,18 +62,6 @@ namespace osu.Game.Rulesets.Catch.UI fruit.CheckPosition = CheckIfWeCanCatch; } - public override void OnJudgement(DrawableHitObject judgedObject, Judgement judgement) - { - if (judgement.IsHit) - { - Vector2 screenPosition = judgedObject.ScreenSpaceDrawQuad.Centre; - - // todo: don't do this - (judgedObject.Parent as Container)?.Remove(judgedObject); - (judgedObject.Parent as Container)?.Remove(judgedObject); - - catcherArea.Add(judgedObject, screenPosition); - } - } + public override void OnJudgement(DrawableHitObject judgedObject, Judgement judgement) => catcherArea.OnJudgement((DrawableCatchHitObject)judgedObject, judgement); } } diff --git a/osu.Game.Rulesets.Catch/UI/CatcherArea.cs b/osu.Game.Rulesets.Catch/UI/CatcherArea.cs index 2bb0f3cd18..63405dce5e 100644 --- a/osu.Game.Rulesets.Catch/UI/CatcherArea.cs +++ b/osu.Game.Rulesets.Catch/UI/CatcherArea.cs @@ -12,6 +12,8 @@ using osu.Framework.Input.Bindings; using osu.Framework.MathUtils; using osu.Game.Beatmaps; using osu.Game.Rulesets.Catch.Objects; +using osu.Game.Rulesets.Catch.Objects.Drawable; +using osu.Game.Rulesets.Judgements; using osu.Game.Rulesets.Objects.Drawables; using OpenTK; using OpenTK.Graphics; @@ -39,17 +41,30 @@ namespace osu.Game.Rulesets.Catch.UI }; } - public void Add(DrawableHitObject fruit, Vector2 absolutePosition) + public void OnJudgement(DrawableCatchHitObject fruit, Judgement judgement) { - fruit.RelativePositionAxes = Axes.None; - fruit.Position = new Vector2(MovableCatcher.ToLocalSpace(absolutePosition).X - MovableCatcher.DrawSize.X / 2, 0); + if (judgement.IsHit) + { + var screenSpacePosition = fruit.ScreenSpaceDrawQuad.Centre; - fruit.Anchor = Anchor.TopCentre; - fruit.Origin = Anchor.BottomCentre; - fruit.Scale *= 0.7f; - fruit.LifetimeEnd = double.MaxValue; + fruit.RelativePositionAxes = Axes.None; + fruit.Position = new Vector2(MovableCatcher.ToLocalSpace(screenSpacePosition).X - MovableCatcher.DrawSize.X / 2, 0); - MovableCatcher.Add(fruit); + fruit.Anchor = Anchor.TopCentre; + fruit.Origin = Anchor.Centre; + fruit.Scale *= 0.7f; + fruit.LifetimeEnd = double.MaxValue; + + MovableCatcher.Add(fruit); + } + + if (fruit.HitObject.LastInCombo) + { + if (judgement.IsHit) + MovableCatcher.Explode(); + else + MovableCatcher.Drop(); + } } public bool AttemptCatch(CatchHitObject obj) => MovableCatcher.AttemptCatch(obj); @@ -176,11 +191,6 @@ namespace osu.Game.Rulesets.Catch.UI } caughtFruit.Add(fruit); - - var catchObject = (CatchHitObject)fruit.HitObject; - - if (catchObject.LastInCombo) - explode(); } /// @@ -309,7 +319,35 @@ namespace osu.Game.Rulesets.Catch.UI X = (float)MathHelper.Clamp(X + direction * Clock.ElapsedFrameTime * BASE_SPEED * dashModifier, 0, 1); } - private void explode() + /// + /// Drop any fruit off the plate. + /// + public void Drop() + { + var fruit = caughtFruit.ToArray(); + + foreach (var f in fruit) + { + if (ExplodingFruitTarget != null) + { + f.Anchor = Anchor.TopLeft; + f.Position = caughtFruit.ToSpaceOfOtherDrawable(f.DrawPosition, ExplodingFruitTarget); + + caughtFruit.Remove(f); + + ExplodingFruitTarget.Add(f); + } + + f.MoveToY(f.Y + 75, 750, Easing.InSine); + f.FadeOut(750); + f.Expire(); + } + } + + /// + /// Explode any fruit off the plate. + /// + public void Explode() { var fruit = caughtFruit.ToArray(); From 22fc9601eee461eed5304dd75c2c6f32395a0394 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 4 Jan 2018 18:33:57 +0900 Subject: [PATCH 2/2] Add back missing code --- osu.Game.Rulesets.Catch/UI/CatcherArea.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/osu.Game.Rulesets.Catch/UI/CatcherArea.cs b/osu.Game.Rulesets.Catch/UI/CatcherArea.cs index 63405dce5e..c266106f58 100644 --- a/osu.Game.Rulesets.Catch/UI/CatcherArea.cs +++ b/osu.Game.Rulesets.Catch/UI/CatcherArea.cs @@ -47,6 +47,11 @@ namespace osu.Game.Rulesets.Catch.UI { var screenSpacePosition = fruit.ScreenSpaceDrawQuad.Centre; + // remove the fruit from its current parent. + // todo: make this less ugly, somehow. + (fruit.Parent as Container)?.Remove(fruit); + (fruit.Parent as Container)?.Remove(fruit); + fruit.RelativePositionAxes = Axes.None; fruit.Position = new Vector2(MovableCatcher.ToLocalSpace(screenSpacePosition).X - MovableCatcher.DrawSize.X / 2, 0);