mirror of
https://github.com/osukey/osukey.git
synced 2025-07-02 16:59:53 +09:00
Remove CatcherArea abstraction
Also fixes catcher size being relative to aspect ratio.
This commit is contained in:
@ -1,10 +1,12 @@
|
||||
// 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.Graphics;
|
||||
using osu.Game.Rulesets.UI;
|
||||
using OpenTK;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Game.Rulesets.Catch.Objects;
|
||||
using osu.Game.Rulesets.Catch.Objects.Drawable;
|
||||
using osu.Game.Rulesets.Judgements;
|
||||
using osu.Game.Rulesets.Objects.Drawables;
|
||||
@ -15,11 +17,15 @@ namespace osu.Game.Rulesets.Catch.UI
|
||||
{
|
||||
protected override Container<Drawable> Content => content;
|
||||
private readonly Container<Drawable> content;
|
||||
private readonly CatcherArea catcherArea;
|
||||
|
||||
private readonly Container catcherContainer;
|
||||
private readonly Catcher catcher;
|
||||
|
||||
public CatchPlayfield()
|
||||
: base(Axes.Y)
|
||||
{
|
||||
Container explodingFruitContainer;
|
||||
|
||||
Reversed.Value = true;
|
||||
|
||||
Size = new Vector2(1);
|
||||
@ -33,16 +39,34 @@ namespace osu.Game.Rulesets.Catch.UI
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
},
|
||||
catcherArea = new CatcherArea
|
||||
explodingFruitContainer = new Container
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
},
|
||||
catcherContainer = new Container {
|
||||
RelativeSizeAxes = Axes.X,
|
||||
Anchor = Anchor.BottomLeft,
|
||||
Origin = Anchor.TopLeft,
|
||||
Height = 0.3f
|
||||
Height = 180,
|
||||
Child = catcher = new Catcher
|
||||
{
|
||||
ExplodingFruitTarget = explodingFruitContainer,
|
||||
RelativePositionAxes = Axes.Both,
|
||||
Origin = Anchor.TopCentre,
|
||||
X = 0.5f,
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
protected override void Update()
|
||||
{
|
||||
base.Update();
|
||||
catcher.Size = new Vector2(catcherContainer.DrawSize.Y);
|
||||
}
|
||||
|
||||
public bool CheckIfWeCanCatch(CatchBaseHit obj) => Math.Abs(catcher.Position.X - obj.X) < catcher.DrawSize.X / DrawSize.X / 2;
|
||||
|
||||
public override void Add(DrawableHitObject h)
|
||||
{
|
||||
h.Depth = (float)h.HitObject.StartTime;
|
||||
@ -50,7 +74,7 @@ namespace osu.Game.Rulesets.Catch.UI
|
||||
base.Add(h);
|
||||
|
||||
var fruit = (DrawableFruit)h;
|
||||
fruit.CheckPosition = catcherArea.CheckIfWeCanCatch;
|
||||
fruit.CheckPosition = CheckIfWeCanCatch;
|
||||
}
|
||||
|
||||
public override void OnJudgement(DrawableHitObject judgedObject, Judgement judgement)
|
||||
@ -59,7 +83,7 @@ namespace osu.Game.Rulesets.Catch.UI
|
||||
{
|
||||
Vector2 screenPosition = judgedObject.ScreenSpaceDrawQuad.Centre;
|
||||
Remove(judgedObject);
|
||||
catcherArea.Add(judgedObject, screenPosition);
|
||||
catcher.Add(judgedObject, screenPosition);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user