2018-01-10 13:52:22 +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;
|
2018-01-10 13:52:22 +08:00
|
|
|
|
using System.Linq;
|
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
|
using osu.Framework.Graphics.Containers;
|
2018-01-12 21:30:21 +08:00
|
|
|
|
using osu.Game.Rulesets.Judgements;
|
2018-01-10 13:52:22 +08:00
|
|
|
|
using osu.Game.Rulesets.Objects.Drawables;
|
2018-01-12 21:30:21 +08:00
|
|
|
|
using osu.Game.Rulesets.Scoring;
|
2018-01-10 13:52:22 +08:00
|
|
|
|
|
|
|
|
|
namespace osu.Game.Rulesets.Catch.Objects.Drawable
|
|
|
|
|
{
|
|
|
|
|
public class DrawableBananaShower : DrawableCatchHitObject<BananaShower>
|
|
|
|
|
{
|
2018-01-10 14:38:12 +08:00
|
|
|
|
private readonly Container bananaContainer;
|
2018-01-10 13:52:22 +08:00
|
|
|
|
|
2018-01-12 20:46:50 +08:00
|
|
|
|
public DrawableBananaShower(BananaShower s, Func<CatchHitObject, DrawableHitObject<CatchHitObject>> getVisualRepresentation = null)
|
2018-01-10 15:58:20 +08:00
|
|
|
|
: base(s)
|
2018-01-10 13:52:22 +08:00
|
|
|
|
{
|
2018-01-11 12:41:50 +08:00
|
|
|
|
RelativeSizeAxes = Axes.X;
|
|
|
|
|
Origin = Anchor.BottomLeft;
|
2018-01-10 13:52:22 +08:00
|
|
|
|
X = 0;
|
|
|
|
|
|
2018-03-15 12:41:06 +08:00
|
|
|
|
InternalChild = bananaContainer = new Container { RelativeSizeAxes = Axes.Both };
|
2018-01-10 13:52:22 +08:00
|
|
|
|
|
2018-01-10 14:38:12 +08:00
|
|
|
|
foreach (var b in s.NestedHitObjects.Cast<BananaShower.Banana>())
|
2018-01-12 20:46:50 +08:00
|
|
|
|
AddNested(getVisualRepresentation?.Invoke(b));
|
2018-01-10 13:52:22 +08:00
|
|
|
|
}
|
|
|
|
|
|
2018-01-12 21:30:21 +08:00
|
|
|
|
protected override void CheckForJudgements(bool userTriggered, double timeOffset)
|
|
|
|
|
{
|
|
|
|
|
if (timeOffset >= 0)
|
|
|
|
|
AddJudgement(new Judgement { Result = NestedHitObjects.Cast<DrawableCatchHitObject>().Any(n => n.Judgements.Any(j => j.IsHit)) ? HitResult.Perfect : HitResult.Miss });
|
|
|
|
|
}
|
|
|
|
|
|
2018-01-11 12:41:50 +08:00
|
|
|
|
protected override void AddNested(DrawableHitObject h)
|
2018-01-10 13:52:22 +08:00
|
|
|
|
{
|
|
|
|
|
((DrawableCatchHitObject)h).CheckPosition = o => CheckPosition?.Invoke(o) ?? false;
|
2018-01-10 14:38:12 +08:00
|
|
|
|
bananaContainer.Add(h);
|
2018-01-10 13:52:22 +08:00
|
|
|
|
base.AddNested(h);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|