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