1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-30 07:07:25 +08:00
osu-lazer/osu.Game.Rulesets.Catch/Skinning/Legacy/LegacyFruitPiece.cs

40 lines
1.3 KiB
C#
Raw Normal View History

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