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

65 lines
1.9 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-06-10 00:38:17 +00:00
using JetBrains.Annotations;
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Game.Rulesets.Catch.Skinning.Default;
using osu.Game.Skinning;
2020-02-19 05:31:32 +00:00
namespace osu.Game.Rulesets.Catch.Objects.Drawables
2018-06-10 00:38:17 +00:00
{
2020-12-09 01:25:35 +00:00
public class DrawableBanana : DrawablePalpableCatchHitObject
2018-06-10 00:38:17 +00:00
{
public DrawableBanana()
: this(null)
{
}
public DrawableBanana([CanBeNull] Banana h)
2018-06-10 00:38:17 +00:00
: base(h)
{
}
2020-02-19 05:31:32 +00:00
[BackgroundDependencyLoader]
private void load()
{
AddInternal(new SkinnableDrawable(
new CatchSkinComponent(CatchSkinComponents.Banana),
_ => new BananaPiece()));
}
protected override void LoadComplete()
{
base.LoadComplete();
// start time affects the random seed which is used to determine the banana colour
StartTimeBindable.BindValueChanged(_ => UpdateComboColour());
}
protected override void UpdateInitialTransforms()
{
base.UpdateInitialTransforms();
const float end_scale = 0.6f;
const float random_scale_range = 1.6f;
this.ScaleTo(HitObject.Scale * (end_scale + random_scale_range * RandomSingle(3)))
.Then().ScaleTo(HitObject.Scale * end_scale, HitObject.TimePreempt);
this.RotateTo(getRandomAngle(1))
.Then()
.RotateTo(getRandomAngle(2), HitObject.TimePreempt);
float getRandomAngle(int series) => 180 * (RandomSingle(series) * 2 - 1);
}
2020-07-30 08:58:49 +00:00
public override void PlaySamples()
{
base.PlaySamples();
if (Samples != null)
Samples.Frequency.Value = 0.77f + ((Banana)HitObject).BananaIndex * 0.006f;
}
2018-06-10 00:38:17 +00:00
}
}