1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 10:52:53 +08:00

Drop fruit when last in combo is not caught

Also cleans up judgement handling a bit
This commit is contained in:
Dean Herbert 2018-01-04 18:13:59 +09:00
parent 6e8e82e264
commit f28053b2fc
2 changed files with 53 additions and 28 deletions

View File

@ -3,7 +3,6 @@
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Game.Rulesets.UI; using osu.Game.Rulesets.UI;
using OpenTK;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Game.Beatmaps; using osu.Game.Beatmaps;
using osu.Game.Rulesets.Catch.Objects; using osu.Game.Rulesets.Catch.Objects;
@ -63,18 +62,6 @@ namespace osu.Game.Rulesets.Catch.UI
fruit.CheckPosition = CheckIfWeCanCatch; fruit.CheckPosition = CheckIfWeCanCatch;
} }
public override void OnJudgement(DrawableHitObject judgedObject, Judgement judgement) public override void OnJudgement(DrawableHitObject judgedObject, Judgement judgement) => catcherArea.OnJudgement((DrawableCatchHitObject)judgedObject, judgement);
{
if (judgement.IsHit)
{
Vector2 screenPosition = judgedObject.ScreenSpaceDrawQuad.Centre;
// todo: don't do this
(judgedObject.Parent as Container<DrawableHitObject>)?.Remove(judgedObject);
(judgedObject.Parent as Container)?.Remove(judgedObject);
catcherArea.Add(judgedObject, screenPosition);
}
}
} }
} }

View File

@ -12,6 +12,8 @@ using osu.Framework.Input.Bindings;
using osu.Framework.MathUtils; using osu.Framework.MathUtils;
using osu.Game.Beatmaps; using osu.Game.Beatmaps;
using osu.Game.Rulesets.Catch.Objects; 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 osu.Game.Rulesets.Objects.Drawables;
using OpenTK; using OpenTK;
using OpenTK.Graphics; 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; if (judgement.IsHit)
fruit.Position = new Vector2(MovableCatcher.ToLocalSpace(absolutePosition).X - MovableCatcher.DrawSize.X / 2, 0); {
var screenSpacePosition = fruit.ScreenSpaceDrawQuad.Centre;
fruit.Anchor = Anchor.TopCentre; fruit.RelativePositionAxes = Axes.None;
fruit.Origin = Anchor.BottomCentre; fruit.Position = new Vector2(MovableCatcher.ToLocalSpace(screenSpacePosition).X - MovableCatcher.DrawSize.X / 2, 0);
fruit.Scale *= 0.7f;
fruit.LifetimeEnd = double.MaxValue;
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); public bool AttemptCatch(CatchHitObject obj) => MovableCatcher.AttemptCatch(obj);
@ -176,11 +191,6 @@ namespace osu.Game.Rulesets.Catch.UI
} }
caughtFruit.Add(fruit); caughtFruit.Add(fruit);
var catchObject = (CatchHitObject)fruit.HitObject;
if (catchObject.LastInCombo)
explode();
} }
/// <summary> /// <summary>
@ -309,7 +319,35 @@ namespace osu.Game.Rulesets.Catch.UI
X = (float)MathHelper.Clamp(X + direction * Clock.ElapsedFrameTime * BASE_SPEED * dashModifier, 0, 1); X = (float)MathHelper.Clamp(X + direction * Clock.ElapsedFrameTime * BASE_SPEED * dashModifier, 0, 1);
} }
private void explode() /// <summary>
/// Drop any fruit off the plate.
/// </summary>
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();
}
}
/// <summary>
/// Explode any fruit off the plate.
/// </summary>
public void Explode()
{ {
var fruit = caughtFruit.ToArray(); var fruit = caughtFruit.ToArray();