Add catching support

This commit is contained in:
Dean Herbert
2017-08-08 12:46:37 +09:00
parent 99a00ed319
commit ff490cf44c
3 changed files with 179 additions and 109 deletions

View File

@ -1,6 +1,7 @@
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System;
using osu.Framework.Allocation;
using osu.Framework.Extensions.Color4Extensions;
using osu.Framework.Graphics;
@ -15,7 +16,7 @@ using OpenTK.Graphics;
namespace osu.Game.Rulesets.Catch.Objects.Drawable
{
internal class DrawableFruit : DrawableScrollingHitObject<CatchBaseHit, CatchJudgement>
public class DrawableFruit : DrawableScrollingHitObject<CatchBaseHit, CatchJudgement>
{
const float pulp_size = 30;
@ -37,7 +38,8 @@ namespace osu.Game.Rulesets.Catch.Objects.Drawable
}
public DrawableFruit(CatchBaseHit h) : base(h)
public DrawableFruit(CatchBaseHit h)
: base(h)
{
Origin = Anchor.Centre;
Size = new Vector2(pulp_size * 2, pulp_size * 2.6f);
@ -50,6 +52,8 @@ namespace osu.Game.Rulesets.Catch.Objects.Drawable
Rotation = (float)(RNG.NextDouble() - 0.5f) * 40;
}
public Func<CatchBaseHit, bool> CheckPosition;
[BackgroundDependencyLoader]
private void load()
{
@ -101,7 +105,7 @@ namespace osu.Game.Rulesets.Catch.Objects.Drawable
protected override void CheckJudgement(bool userTriggered)
{
if (Judgement.TimeOffset > 0)
Judgement.Result = HitResult.Miss;
Judgement.Result = CheckPosition?.Invoke(HitObject) ?? false ? HitResult.Hit : HitResult.Miss;
}
protected override void UpdateState(ArmedState state)