2020-02-17 10:06:08 +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.
|
|
|
|
|
|
|
|
using osu.Framework.Bindables;
|
2020-12-07 03:57:24 +00:00
|
|
|
using osu.Framework.Graphics.Textures;
|
2020-02-19 09:01:59 +00:00
|
|
|
using osu.Game.Rulesets.Catch.Objects.Drawables;
|
2020-02-17 10:06:08 +00:00
|
|
|
|
|
|
|
namespace osu.Game.Rulesets.Catch.Skinning
|
|
|
|
{
|
2020-12-07 03:57:24 +00:00
|
|
|
internal class LegacyFruitPiece : LegacyCatchHitObjectPiece
|
2020-02-17 10:06:08 +00:00
|
|
|
{
|
2020-12-07 03:57:24 +00:00
|
|
|
public readonly Bindable<FruitVisualRepresentation> VisualRepresentation = new Bindable<FruitVisualRepresentation>();
|
2020-02-17 10:06:08 +00:00
|
|
|
|
2020-12-07 03:57:24 +00:00
|
|
|
private readonly string[] lookupNames =
|
2020-02-17 10:06:08 +00:00
|
|
|
{
|
2020-12-07 03:57:24 +00:00
|
|
|
"fruit-pear", "fruit-grapes", "fruit-apple", "fruit-orange", "fruit-bananas"
|
|
|
|
};
|
2020-02-17 10:06:08 +00:00
|
|
|
|
2020-12-07 03:57:24 +00:00
|
|
|
protected override void LoadComplete()
|
2020-02-17 10:06:08 +00:00
|
|
|
{
|
2020-12-07 03:57:24 +00:00
|
|
|
base.LoadComplete();
|
2020-02-17 10:06:08 +00:00
|
|
|
|
2020-12-07 03:57:24 +00:00
|
|
|
var fruit = (DrawableFruit)DrawableHitObject;
|
2020-02-26 10:22:46 +00:00
|
|
|
|
2020-12-07 03:57:24 +00:00
|
|
|
if (fruit != null)
|
|
|
|
VisualRepresentation.BindTo(fruit.VisualRepresentation);
|
2020-02-26 10:22:46 +00:00
|
|
|
|
2020-12-07 03:57:24 +00:00
|
|
|
VisualRepresentation.BindValueChanged(visual => setTexture(visual.NewValue), true);
|
2020-02-17 10:06:08 +00:00
|
|
|
}
|
2020-02-19 02:23:45 +00:00
|
|
|
|
2020-12-07 03:57:24 +00:00
|
|
|
private void setTexture(FruitVisualRepresentation visualRepresentation)
|
2020-02-19 02:23:45 +00:00
|
|
|
{
|
2020-12-07 03:57:24 +00:00
|
|
|
Texture texture = Skin.GetTexture(lookupNames[(int)visualRepresentation]);
|
|
|
|
Texture overlayTexture = Skin.GetTexture(lookupNames[(int)visualRepresentation] + "-overlay");
|
2020-02-19 02:23:45 +00:00
|
|
|
|
2020-12-07 03:57:24 +00:00
|
|
|
SetTexture(texture, overlayTexture);
|
2020-02-19 02:23:45 +00:00
|
|
|
}
|
2020-02-17 10:06:08 +00:00
|
|
|
}
|
|
|
|
}
|