1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-12 14:40:04 +08:00
osu-lazer/osu.Game.Rulesets.Catch/Objects/Drawables/DrawableFruit.cs

56 lines
1.5 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 17:19:50 +08:00
using JetBrains.Annotations;
2018-04-13 17:19:50 +08:00
using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
2020-12-07 11:35:24 +08:00
using osu.Game.Rulesets.Catch.Skinning.Default;
using osu.Game.Skinning;
2018-04-13 17:19:50 +08:00
namespace osu.Game.Rulesets.Catch.Objects.Drawables
2018-04-13 17:19:50 +08:00
{
2020-12-09 09:25:35 +08:00
public class DrawableFruit : DrawablePalpableCatchHitObject, IHasFruitState
2018-04-13 17:19:50 +08:00
{
public Bindable<FruitVisualRepresentation> VisualRepresentation { get; } = new Bindable<FruitVisualRepresentation>();
public DrawableFruit()
: this(null)
{
}
public DrawableFruit([CanBeNull] Fruit h)
2018-04-13 17:19:50 +08:00
: base(h)
{
}
[BackgroundDependencyLoader]
private void load()
{
IndexInBeatmap.BindValueChanged(change =>
{
VisualRepresentation.Value = (FruitVisualRepresentation)(change.NewValue % 4);
}, true);
ScalingContainer.Child = new SkinnableDrawable(
new CatchSkinComponent(CatchSkinComponents.Fruit),
_ => new FruitPiece());
}
protected override void UpdateInitialTransforms()
2018-04-13 17:19:50 +08:00
{
base.UpdateInitialTransforms();
2018-04-13 17:19:50 +08:00
ScalingContainer.RotateTo((RandomSingle(1) - 0.5f) * 40);
2018-04-13 17:19:50 +08:00
}
}
public enum FruitVisualRepresentation
{
Pear,
Grape,
Pineapple,
Raspberry,
}
2018-04-13 17:19:50 +08:00
}