Don't inherit DrawableFruit from DrawableBanana

- A banana cannot be hyper
This commit is contained in:
ekrctb
2020-12-07 14:08:50 +09:00
parent c0f39514b9
commit 7f1ad1040d
8 changed files with 76 additions and 15 deletions

View File

@ -2,14 +2,15 @@
// See the LICENCE file in the repository root for full licence text.
using JetBrains.Annotations;
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Game.Rulesets.Catch.Objects.Drawables.Pieces;
using osu.Game.Skinning;
namespace osu.Game.Rulesets.Catch.Objects.Drawables
{
public class DrawableBanana : DrawableFruit
public class DrawableBanana : DrawablePalpableCatchHitObject
{
protected override FruitVisualRepresentation GetVisualRepresentation(int indexInBeatmap) => FruitVisualRepresentation.Banana;
public DrawableBanana()
: this(null)
{
@ -20,6 +21,14 @@ namespace osu.Game.Rulesets.Catch.Objects.Drawables
{
}
[BackgroundDependencyLoader]
private void load()
{
ScaleContainer.Child = new SkinnableDrawable(
new CatchSkinComponent(CatchSkinComponents.Banana),
_ => new BananaPiece());
}
protected override void LoadComplete()
{
base.LoadComplete();

View File

@ -14,8 +14,6 @@ namespace osu.Game.Rulesets.Catch.Objects.Drawables
{
public readonly Bindable<FruitVisualRepresentation> VisualRepresentation = new Bindable<FruitVisualRepresentation>();
protected virtual FruitVisualRepresentation GetVisualRepresentation(int indexInBeatmap) => (FruitVisualRepresentation)(indexInBeatmap % 4);
public DrawableFruit()
: this(null)
{
@ -31,11 +29,11 @@ namespace osu.Game.Rulesets.Catch.Objects.Drawables
{
IndexInBeatmap.BindValueChanged(change =>
{
VisualRepresentation.Value = GetVisualRepresentation(change.NewValue);
VisualRepresentation.Value = (FruitVisualRepresentation)(change.NewValue % 4);
}, true);
ScaleContainer.Child = new SkinnableDrawable(
new CatchSkinComponent(this is DrawableBanana ? CatchSkinComponents.Banana : CatchSkinComponents.Fruit),
new CatchSkinComponent(CatchSkinComponents.Fruit),
_ => new FruitPiece());
}
@ -53,6 +51,5 @@ namespace osu.Game.Rulesets.Catch.Objects.Drawables
Grape,
Pineapple,
Raspberry,
Banana // banananananannaanana
}
}

View File

@ -0,0 +1,24 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using osu.Framework.Graphics;
namespace osu.Game.Rulesets.Catch.Objects.Drawables.Pieces
{
public class BananaPiece : CatchHitObjectPiece
{
public BananaPiece()
{
RelativeSizeAxes = Axes.Both;
InternalChildren = new Drawable[]
{
new BananaPulpFormation
{
AccentColour = { BindTarget = AccentColour },
},
BorderPiece = new BorderPiece(),
};
}
}
}

View File

@ -0,0 +1,16 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using osuTK;
namespace osu.Game.Rulesets.Catch.Objects.Drawables.Pieces
{
public class BananaPulpFormation : PulpFormation
{
public BananaPulpFormation()
{
Add(new Vector2(0, -0.3f), new Vector2(SMALL_PULP));
Add(new Vector2(0, 0.05f), new Vector2(LARGE_PULP_4 * 0.8f, LARGE_PULP_4 * 2.5f));
}
}
}

View File

@ -52,11 +52,6 @@ namespace osu.Game.Rulesets.Catch.Objects.Drawables.Pieces
Add(PositionAt(180, DISTANCE_FROM_CENTRE_4), new Vector2(LARGE_PULP_4));
Add(PositionAt(270, DISTANCE_FROM_CENTRE_4), new Vector2(LARGE_PULP_4));
break;
case FruitVisualRepresentation.Banana:
Add(new Vector2(0, -0.3f), new Vector2(SMALL_PULP));
Add(new Vector2(0, 0.05f), new Vector2(LARGE_PULP_4 * 0.8f, LARGE_PULP_4 * 2.5f));
break;
}
}
}