1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-17 01:32:55 +08:00
osu-lazer/osu.Game.Rulesets.Catch/UI/CatchPlayfield.cs

66 lines
2.0 KiB
C#
Raw Normal View History

// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using osu.Framework.Graphics;
2017-04-18 15:05:58 +08:00
using osu.Game.Rulesets.UI;
using OpenTK;
2017-08-08 09:35:56 +08:00
using osu.Framework.Graphics.Containers;
2017-08-08 11:46:37 +08:00
using osu.Game.Rulesets.Catch.Objects.Drawable;
using osu.Game.Rulesets.Judgements;
2017-08-08 11:46:37 +08:00
using osu.Game.Rulesets.Objects.Drawables;
2017-04-18 15:05:58 +08:00
namespace osu.Game.Rulesets.Catch.UI
{
public class CatchPlayfield : ScrollingPlayfield
{
2017-08-08 09:35:56 +08:00
protected override Container<Drawable> Content => content;
private readonly Container<Drawable> content;
2017-08-08 11:46:37 +08:00
private readonly CatcherArea catcherArea;
2017-08-08 09:35:56 +08:00
public CatchPlayfield()
2017-08-08 09:35:56 +08:00
: base(Axes.Y)
{
2017-08-08 12:31:55 +08:00
Reversed.Value = true;
2017-08-02 19:41:38 +08:00
Size = new Vector2(1);
Anchor = Anchor.TopCentre;
Origin = Anchor.TopCentre;
2017-08-08 09:35:56 +08:00
InternalChildren = new Drawable[]
2017-08-02 19:28:24 +08:00
{
2017-08-08 09:35:56 +08:00
content = new Container<Drawable>
{
RelativeSizeAxes = Axes.Both,
},
2017-08-08 11:46:37 +08:00
catcherArea = new CatcherArea
2017-08-02 19:28:24 +08:00
{
RelativeSizeAxes = Axes.Both,
2017-08-07 14:09:31 +08:00
Anchor = Anchor.BottomLeft,
Origin = Anchor.TopLeft,
Height = 0.3f
2017-08-02 19:28:24 +08:00
}
};
}
2017-08-08 11:46:37 +08:00
public override void Add(DrawableHitObject h)
2017-08-08 11:46:37 +08:00
{
base.Add(h);
var fruit = (DrawableFruit)h;
fruit.CheckPosition = catcherArea.CheckIfWeCanCatch;
fruit.OnJudgement += Fruit_OnJudgement;
}
private void Fruit_OnJudgement(DrawableHitObject judgedObject, Judgement judgement)
2017-08-08 11:46:37 +08:00
{
2017-09-12 16:36:46 +08:00
if (judgement.IsHit)
2017-08-08 11:46:37 +08:00
{
Vector2 screenPosition = judgedObject.ScreenSpaceDrawQuad.Centre;
Remove(judgedObject);
catcherArea.Add(judgedObject, screenPosition);
2017-08-08 11:46:37 +08:00
}
}
}
2017-08-08 09:35:56 +08:00
}