Merge pull request #1853 from peppy/drop-fruit

Drop fruit when last in combo is not caught
This commit is contained in:
Dan Balasescu 2018-01-10 13:35:18 +09:00 committed by GitHub
commit 4f8ce272ae
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 57 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;
@ -66,18 +65,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,34 @@ 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; // todo: make this less ugly, somehow.
fruit.Origin = Anchor.Centre; (fruit.Parent as Container<DrawableHitObject>)?.Remove(fruit);
fruit.Scale *= 0.7f; (fruit.Parent as Container)?.Remove(fruit);
fruit.LifetimeEnd = double.MaxValue;
MovableCatcher.Add(fruit); fruit.RelativePositionAxes = Axes.None;
fruit.Position = new Vector2(MovableCatcher.ToLocalSpace(screenSpacePosition).X - MovableCatcher.DrawSize.X / 2, 0);
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);
@ -184,11 +203,6 @@ namespace osu.Game.Rulesets.Catch.UI
fruit.X = MathHelper.Clamp(fruit.X, -CATCHER_SIZE / 2, CATCHER_SIZE / 2); fruit.X = MathHelper.Clamp(fruit.X, -CATCHER_SIZE / 2, CATCHER_SIZE / 2);
caughtFruit.Add(fruit); caughtFruit.Add(fruit);
var catchObject = (CatchHitObject)fruit.HitObject;
if (catchObject.LastInCombo)
explode();
} }
/// <summary> /// <summary>
@ -317,7 +331,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();