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