osu/osu.Game.Rulesets.Catch/Objects/Drawables/DrawableFruit.cs

59 lines
1.7 KiB
C#
Raw Normal View History

// 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.
2018-04-13 09:19:50 +00:00
using JetBrains.Annotations;
2018-04-13 09:19:50 +00:00
using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
2020-11-26 05:26:38 +00:00
using osu.Game.Rulesets.Catch.Objects.Drawables.Pieces;
using osu.Game.Skinning;
2018-04-13 09:19:50 +00:00
namespace osu.Game.Rulesets.Catch.Objects.Drawables
2018-04-13 09:19:50 +00:00
{
public class DrawableFruit : DrawablePalpableCatchHitObject
2018-04-13 09:19:50 +00:00
{
public readonly Bindable<FruitVisualRepresentation> VisualRepresentation = new Bindable<FruitVisualRepresentation>();
protected virtual FruitVisualRepresentation GetVisualRepresentation(int indexInBeatmap) => (FruitVisualRepresentation)(indexInBeatmap % 4);
public DrawableFruit()
: this(null)
{
}
public DrawableFruit([CanBeNull] Fruit h)
2018-04-13 09:19:50 +00:00
: base(h)
{
}
[BackgroundDependencyLoader]
private void load()
{
IndexInBeatmap.BindValueChanged(change =>
{
VisualRepresentation.Value = GetVisualRepresentation(change.NewValue);
}, true);
ScaleContainer.Child = new SkinnableDrawable(
new CatchSkinComponent(this is DrawableBanana ? CatchSkinComponents.Banana : CatchSkinComponents.Fruit),
_ => new FruitPiece());
}
protected override void UpdateInitialTransforms()
2018-04-13 09:19:50 +00:00
{
base.UpdateInitialTransforms();
2018-04-13 09:19:50 +00:00
ScaleContainer.RotateTo((RandomSingle(1) - 0.5f) * 40);
2018-04-13 09:19:50 +00:00
}
}
public enum FruitVisualRepresentation
{
Pear,
Grape,
Pineapple,
Raspberry,
Banana // banananananannaanana
}
2018-04-13 09:19:50 +00:00
}