osu/osu.Game.Rulesets.Catch/UI/CatchPlayfield.cs

67 lines
2.1 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 07:05:58 +00:00
using osu.Game.Rulesets.Catch.Objects;
using osu.Game.Rulesets.UI;
using OpenTK;
2017-04-18 07:05:58 +00:00
using osu.Game.Rulesets.Catch.Judgements;
2017-08-08 01:35:56 +00:00
using osu.Framework.Graphics.Containers;
2017-08-08 03:46:37 +00:00
using osu.Game.Rulesets.Catch.Objects.Drawable;
using osu.Game.Rulesets.Objects.Drawables;
2017-04-18 07:05:58 +00:00
namespace osu.Game.Rulesets.Catch.UI
{
2017-08-08 01:35:56 +00:00
public class CatchPlayfield : ScrollingPlayfield<CatchBaseHit, CatchJudgement>
{
2017-08-08 01:35:56 +00:00
protected override Container<Drawable> Content => content;
private readonly Container<Drawable> content;
2017-08-08 03:46:37 +00:00
private readonly CatcherArea catcherArea;
2017-08-08 01:35:56 +00:00
public CatchPlayfield()
2017-08-08 01:35:56 +00:00
: base(Axes.Y)
{
2017-08-08 04:31:55 +00:00
Reversed.Value = true;
2017-08-02 11:41:38 +00:00
Size = new Vector2(1);
Anchor = Anchor.TopCentre;
Origin = Anchor.TopCentre;
2017-08-08 01:35:56 +00:00
InternalChildren = new Drawable[]
2017-08-02 11:28:24 +00:00
{
2017-08-08 01:35:56 +00:00
content = new Container<Drawable>
{
RelativeSizeAxes = Axes.Both,
},
2017-08-08 03:46:37 +00:00
catcherArea = new CatcherArea
2017-08-02 11:28:24 +00:00
{
RelativeSizeAxes = Axes.Both,
2017-08-07 06:09:31 +00:00
Anchor = Anchor.BottomLeft,
Origin = Anchor.TopLeft,
Height = 0.3f
2017-08-02 11:28:24 +00:00
}
};
}
2017-08-08 03:46:37 +00:00
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);
}
}
}
2017-08-08 01:35:56 +00:00
}