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

@ -7,6 +7,8 @@ using osu.Game.Rulesets.UI;
using OpenTK;
using osu.Game.Rulesets.Catch.Judgements;
using osu.Framework.Graphics.Containers;
using osu.Game.Rulesets.Catch.Objects.Drawable;
using osu.Game.Rulesets.Objects.Drawables;
namespace osu.Game.Rulesets.Catch.UI
{
@ -14,6 +16,7 @@ namespace osu.Game.Rulesets.Catch.UI
{
protected override Container<Drawable> Content => content;
private readonly Container<Drawable> content;
private readonly CatcherArea catcherArea;
public CatchPlayfield()
: base(Axes.Y)
@ -31,7 +34,7 @@ namespace osu.Game.Rulesets.Catch.UI
RelativeSizeAxes = Axes.Both,
Origin = Anchor.BottomLeft
},
new CatcherArea
catcherArea = new CatcherArea
{
RelativeSizeAxes = Axes.Both,
Anchor = Anchor.BottomLeft,
@ -40,5 +43,24 @@ namespace osu.Game.Rulesets.Catch.UI
}
};
}
public override void Add(DrawableHitObject<CatchBaseHit, CatchJudgement> h)
{
base.Add(h);
var fruit = (DrawableFruit)h;
fruit.CheckPosition = catcherArea.CheckIfWeCanCatch;
fruit.OnJudgement += Fruit_OnJudgement;
}
private void Fruit_OnJudgement(DrawableHitObject<CatchBaseHit, CatchJudgement> obj)
{
if (obj.Judgement.Result == HitResult.Hit)
{
Vector2 screenPosition = obj.ScreenSpaceDrawQuad.Centre;
Remove(obj);
catcherArea.Add(obj, screenPosition);
}
}
}
}