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