1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-15 06:52:56 +08:00
osu-lazer/osu.Game.Rulesets.Catch/UI/CatchPlayfield.cs

72 lines
2.5 KiB
C#
Raw Normal View History

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