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