2018-01-05 11:21:19 +00:00
|
|
|
|
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
2017-02-07 04:59:30 +00:00
|
|
|
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
2016-09-02 11:30:27 +00:00
|
|
|
|
|
2018-01-12 12:46:50 +00:00
|
|
|
|
using System;
|
2016-09-02 11:30:27 +00:00
|
|
|
|
using osu.Framework.Graphics;
|
2017-08-08 01:35:56 +00:00
|
|
|
|
using osu.Framework.Graphics.Containers;
|
2017-11-28 09:39:45 +00:00
|
|
|
|
using osu.Game.Beatmaps;
|
2017-10-02 13:55:37 +00:00
|
|
|
|
using osu.Game.Rulesets.Catch.Objects;
|
2017-08-08 03:46:37 +00:00
|
|
|
|
using osu.Game.Rulesets.Catch.Objects.Drawable;
|
2017-09-06 08:02:13 +00:00
|
|
|
|
using osu.Game.Rulesets.Judgements;
|
2017-08-08 03:46:37 +00:00
|
|
|
|
using osu.Game.Rulesets.Objects.Drawables;
|
2018-01-04 10:22:15 +00:00
|
|
|
|
using osu.Game.Rulesets.UI.Scrolling;
|
2016-09-02 11:30:27 +00:00
|
|
|
|
|
2017-04-18 07:05:58 +00:00
|
|
|
|
namespace osu.Game.Rulesets.Catch.UI
|
2016-09-02 11:30:27 +00:00
|
|
|
|
{
|
2017-09-12 09:19:28 +00:00
|
|
|
|
public class CatchPlayfield : ScrollingPlayfield
|
2016-09-02 11:30:27 +00:00
|
|
|
|
{
|
2017-12-01 06:08:12 +00:00
|
|
|
|
public const float BASE_WIDTH = 512;
|
2017-10-10 07:34:01 +00:00
|
|
|
|
|
2017-08-08 01:35:56 +00:00
|
|
|
|
protected override Container<Drawable> Content => content;
|
|
|
|
|
private readonly Container<Drawable> content;
|
2017-10-02 13:55:37 +00:00
|
|
|
|
|
2017-11-28 09:39:45 +00:00
|
|
|
|
private readonly CatcherArea catcherArea;
|
2017-08-08 01:35:56 +00:00
|
|
|
|
|
2018-01-12 12:46:50 +00:00
|
|
|
|
public CatchPlayfield(BeatmapDifficulty difficulty, Func<CatchHitObject, DrawableHitObject<CatchHitObject>> getVisualRepresentation)
|
2018-01-10 09:05:19 +00:00
|
|
|
|
: base(ScrollingDirection.Down, BASE_WIDTH)
|
2016-09-02 11:30:27 +00:00
|
|
|
|
{
|
2017-10-02 13:55:37 +00:00
|
|
|
|
Container explodingFruitContainer;
|
|
|
|
|
|
2017-08-02 11:41:38 +00:00
|
|
|
|
Anchor = Anchor.TopCentre;
|
|
|
|
|
Origin = Anchor.TopCentre;
|
2016-09-02 11:30:27 +00:00
|
|
|
|
|
2018-01-04 07:28:36 +00:00
|
|
|
|
ScaledContent.Anchor = Anchor.BottomLeft;
|
|
|
|
|
ScaledContent.Origin = Anchor.BottomLeft;
|
|
|
|
|
|
|
|
|
|
ScaledContent.AddRange(new Drawable[]
|
2017-08-02 11:28:24 +00:00
|
|
|
|
{
|
2017-10-02 13:55:37 +00:00
|
|
|
|
explodingFruitContainer = new Container
|
2017-08-02 11:28:24 +00:00
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
2017-10-02 13:55:37 +00:00
|
|
|
|
},
|
2017-11-28 09:39:45 +00:00
|
|
|
|
catcherArea = new CatcherArea(difficulty)
|
2017-10-02 14:24:22 +00:00
|
|
|
|
{
|
2018-01-12 12:46:50 +00:00
|
|
|
|
GetVisualRepresentation = getVisualRepresentation,
|
2017-11-28 09:39:45 +00:00
|
|
|
|
ExplodingFruitTarget = explodingFruitContainer,
|
2017-08-07 06:09:31 +00:00
|
|
|
|
Anchor = Anchor.BottomLeft,
|
|
|
|
|
Origin = Anchor.TopLeft,
|
2018-02-01 10:22:31 +00:00
|
|
|
|
},
|
|
|
|
|
content = new Container<Drawable>
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
},
|
2018-01-04 07:28:36 +00:00
|
|
|
|
});
|
2016-09-02 11:30:27 +00:00
|
|
|
|
}
|
2017-08-08 03:46:37 +00:00
|
|
|
|
|
2017-12-01 10:24:48 +00:00
|
|
|
|
public bool CheckIfWeCanCatch(CatchHitObject obj) => catcherArea.AttemptCatch(obj);
|
2017-10-02 13:55:37 +00:00
|
|
|
|
|
2017-09-12 09:19:28 +00:00
|
|
|
|
public override void Add(DrawableHitObject h)
|
2017-08-08 03:46:37 +00:00
|
|
|
|
{
|
2017-09-13 07:17:01 +00:00
|
|
|
|
h.Depth = (float)h.HitObject.StartTime;
|
2018-01-16 06:37:32 +00:00
|
|
|
|
h.OnJudgement += onJudgement;
|
2017-09-13 07:17:01 +00:00
|
|
|
|
|
2017-08-08 03:46:37 +00:00
|
|
|
|
base.Add(h);
|
|
|
|
|
|
2017-10-10 07:34:01 +00:00
|
|
|
|
var fruit = (DrawableCatchHitObject)h;
|
2017-10-02 13:55:37 +00:00
|
|
|
|
fruit.CheckPosition = CheckIfWeCanCatch;
|
2017-08-08 03:46:37 +00:00
|
|
|
|
}
|
|
|
|
|
|
2018-01-16 06:37:32 +00:00
|
|
|
|
private void onJudgement(DrawableHitObject judgedObject, Judgement judgement) => catcherArea.OnJudgement((DrawableCatchHitObject)judgedObject, judgement);
|
2016-09-02 11:30:27 +00:00
|
|
|
|
}
|
2017-08-08 01:35:56 +00:00
|
|
|
|
}
|