1
0
mirror of https://github.com/ppy/osu.git synced 2025-03-06 18:27:18 +08:00

79 lines
2.7 KiB
C#
Raw Normal View History

// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
2018-04-13 18:19:50 +09:00
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Game.Beatmaps;
2018-06-29 16:49:01 +09:00
using osu.Game.Rulesets.Catch.Judgements;
using osu.Game.Rulesets.Catch.Objects.Drawables;
2018-04-13 18:19:50 +09:00
using osu.Game.Rulesets.Catch.Replays;
using osu.Game.Rulesets.Judgements;
2020-09-29 14:26:36 +09:00
using osu.Game.Rulesets.Scoring;
2018-06-11 23:00:26 +09:00
using osu.Game.Rulesets.UI;
2018-11-20 16:51:59 +09:00
using osuTK;
2018-04-13 18:19:50 +09:00
namespace osu.Game.Rulesets.Catch.UI
{
public class CatcherArea : Container
{
2019-01-31 17:57:59 +01:00
public const float CATCHER_SIZE = 106.75f;
2018-04-13 18:19:50 +09:00
public readonly Catcher MovableCatcher;
2020-09-12 22:39:06 +02:00
private readonly CatchComboDisplay comboDisplay;
public CatcherArea(Container<CaughtObject> droppedObjectContainer, BeatmapDifficulty difficulty = null)
2018-04-13 18:19:50 +09:00
{
Size = new Vector2(CatchPlayfield.WIDTH, CATCHER_SIZE);
Children = new Drawable[]
{
2020-09-12 22:39:06 +02:00
comboDisplay = new CatchComboDisplay
{
RelativeSizeAxes = Axes.None,
AutoSizeAxes = Axes.Both,
Anchor = Anchor.TopLeft,
Origin = Anchor.Centre,
Margin = new MarginPadding { Bottom = 350f },
X = CatchPlayfield.CENTER_X
},
2020-12-04 10:21:54 +09:00
MovableCatcher = new Catcher(this, droppedObjectContainer, difficulty) { X = CatchPlayfield.CENTER_X },
};
}
2018-04-13 18:19:50 +09:00
public void OnNewResult(DrawableCatchHitObject hitObject, JudgementResult result)
2018-04-13 18:19:50 +09:00
{
MovableCatcher.OnNewResult(hitObject, result);
2020-09-29 14:26:36 +09:00
if (!result.Type.IsScorable())
return;
if (hitObject.HitObject.LastInCombo)
2018-04-13 18:19:50 +09:00
{
if (result.Judgement is CatchJudgement catchJudgement && catchJudgement.ShouldExplodeFor(result))
MovableCatcher.Explode();
2018-04-13 18:19:50 +09:00
else
MovableCatcher.Drop();
}
2020-09-12 22:39:06 +02:00
comboDisplay.OnNewResult(hitObject, result);
2018-04-13 18:19:50 +09:00
}
public void OnRevertResult(DrawableCatchHitObject hitObject, JudgementResult result)
{
comboDisplay.OnRevertResult(hitObject, result);
MovableCatcher.OnRevertResult(hitObject, result);
2018-04-13 18:19:50 +09:00
}
protected override void UpdateAfterChildren()
{
base.UpdateAfterChildren();
var state = (GetContainingInputManager().CurrentState as RulesetInputManagerInputState<CatchAction>)?.LastReplayState as CatchFramedReplayInputHandler.CatchReplayState;
if (state?.CatcherX != null)
MovableCatcher.X = state.CatcherX.Value;
2020-09-12 22:39:06 +02:00
comboDisplay.X = MovableCatcher.X;
}
}
2018-04-13 18:19:50 +09:00
}