2020-07-29 21:31:18 +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.Allocation;
|
|
|
|
using osu.Framework.Graphics;
|
2020-11-05 17:12:02 +08:00
|
|
|
using osu.Framework.Graphics.Containers;
|
2020-07-29 21:31:18 +08:00
|
|
|
using osu.Framework.Graphics.Sprites;
|
2020-07-30 11:05:19 +08:00
|
|
|
using osu.Framework.Utils;
|
2020-07-29 21:31:18 +08:00
|
|
|
using osu.Game.Rulesets.Objects.Drawables;
|
2020-11-05 14:18:52 +08:00
|
|
|
using osu.Game.Rulesets.Osu.Objects;
|
2020-07-29 21:31:18 +08:00
|
|
|
using osu.Game.Rulesets.Osu.Objects.Drawables;
|
|
|
|
using osu.Game.Skinning;
|
2020-07-30 11:05:19 +08:00
|
|
|
using osuTK;
|
|
|
|
using osuTK.Graphics;
|
2020-07-29 21:31:18 +08:00
|
|
|
|
|
|
|
namespace osu.Game.Rulesets.Osu.Skinning
|
|
|
|
{
|
2020-07-30 09:35:48 +08:00
|
|
|
/// <summary>
|
|
|
|
/// Legacy skinned spinner with two main spinning layers, one fixed overlay and one final spinning overlay.
|
|
|
|
/// No background layer.
|
|
|
|
/// </summary>
|
2020-11-05 17:00:26 +08:00
|
|
|
public class LegacyNewStyleSpinner : LegacySpinner
|
2020-07-29 21:31:18 +08:00
|
|
|
{
|
2020-11-05 16:12:35 +08:00
|
|
|
private Sprite glow;
|
2020-07-29 21:31:18 +08:00
|
|
|
private Sprite discBottom;
|
|
|
|
private Sprite discTop;
|
|
|
|
private Sprite spinningMiddle;
|
2020-07-30 11:05:19 +08:00
|
|
|
private Sprite fixedMiddle;
|
2020-07-29 21:31:18 +08:00
|
|
|
|
2020-11-05 16:12:35 +08:00
|
|
|
private readonly Color4 glowColour = new Color4(3, 151, 255, 255);
|
|
|
|
|
2020-11-05 17:12:02 +08:00
|
|
|
private Container scaleContainer;
|
|
|
|
|
2020-07-29 21:31:18 +08:00
|
|
|
[BackgroundDependencyLoader]
|
2020-11-05 17:00:26 +08:00
|
|
|
private void load(ISkinSource source)
|
2020-07-29 21:31:18 +08:00
|
|
|
{
|
2020-11-05 17:12:02 +08:00
|
|
|
AddInternal(scaleContainer = new Container
|
2020-07-29 21:31:18 +08:00
|
|
|
{
|
2020-11-05 18:05:59 +08:00
|
|
|
Scale = new Vector2(SPRITE_SCALE),
|
2020-11-05 17:12:02 +08:00
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
Children = new Drawable[]
|
2020-07-29 21:31:18 +08:00
|
|
|
{
|
2020-11-05 17:12:02 +08:00
|
|
|
glow = new Sprite
|
|
|
|
{
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
Texture = source.GetTexture("spinner-glow"),
|
|
|
|
Blending = BlendingParameters.Additive,
|
|
|
|
Colour = glowColour,
|
|
|
|
},
|
|
|
|
discBottom = new Sprite
|
|
|
|
{
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
Texture = source.GetTexture("spinner-bottom")
|
|
|
|
},
|
|
|
|
discTop = new Sprite
|
|
|
|
{
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
Texture = source.GetTexture("spinner-top")
|
|
|
|
},
|
|
|
|
fixedMiddle = new Sprite
|
|
|
|
{
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
Texture = source.GetTexture("spinner-middle")
|
|
|
|
},
|
|
|
|
spinningMiddle = new Sprite
|
|
|
|
{
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
Texture = source.GetTexture("spinner-middle2")
|
|
|
|
}
|
2020-07-29 21:31:18 +08:00
|
|
|
}
|
2020-11-05 17:03:24 +08:00
|
|
|
});
|
2020-07-29 21:31:18 +08:00
|
|
|
}
|
|
|
|
|
2020-11-05 17:00:26 +08:00
|
|
|
protected override void UpdateStateTransforms(DrawableHitObject drawableHitObject, ArmedState state)
|
2020-07-29 21:31:18 +08:00
|
|
|
{
|
2020-11-05 17:00:26 +08:00
|
|
|
base.UpdateStateTransforms(drawableHitObject, state);
|
2020-07-29 21:31:18 +08:00
|
|
|
|
2020-11-05 16:12:35 +08:00
|
|
|
switch (drawableHitObject)
|
|
|
|
{
|
|
|
|
case DrawableSpinner d:
|
|
|
|
Spinner spinner = d.HitObject;
|
2020-10-01 19:38:47 +08:00
|
|
|
|
2020-11-05 16:12:35 +08:00
|
|
|
using (BeginAbsoluteSequence(spinner.StartTime - spinner.TimePreempt, true))
|
|
|
|
this.FadeOut();
|
2020-11-05 14:18:52 +08:00
|
|
|
|
2020-11-05 16:12:35 +08:00
|
|
|
using (BeginAbsoluteSequence(spinner.StartTime - spinner.TimeFadeIn / 2, true))
|
|
|
|
this.FadeInFromZero(spinner.TimeFadeIn / 2);
|
2020-10-02 15:17:57 +08:00
|
|
|
|
2020-11-05 16:12:35 +08:00
|
|
|
using (BeginAbsoluteSequence(spinner.StartTime - spinner.TimePreempt, true))
|
|
|
|
{
|
|
|
|
fixedMiddle.FadeColour(Color4.White);
|
2020-07-30 11:05:19 +08:00
|
|
|
|
2020-11-05 16:12:35 +08:00
|
|
|
using (BeginDelayedSequence(spinner.TimePreempt, true))
|
|
|
|
fixedMiddle.FadeColour(Color4.Red, spinner.Duration);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (state == ArmedState.Hit)
|
|
|
|
{
|
|
|
|
using (BeginAbsoluteSequence(d.HitStateUpdateTime))
|
|
|
|
glow.FadeOut(300);
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
2020-10-02 15:17:57 +08:00
|
|
|
|
2020-11-05 16:12:35 +08:00
|
|
|
case DrawableSpinnerBonusTick _:
|
|
|
|
if (state == ArmedState.Hit)
|
|
|
|
glow.FlashColour(Color4.White, 200);
|
|
|
|
|
|
|
|
break;
|
2020-10-02 15:17:57 +08:00
|
|
|
}
|
2020-07-29 21:31:18 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
protected override void Update()
|
|
|
|
{
|
|
|
|
base.Update();
|
2020-11-05 17:00:26 +08:00
|
|
|
spinningMiddle.Rotation = discTop.Rotation = DrawableSpinner.RotationTracker.Rotation;
|
2020-07-29 21:31:18 +08:00
|
|
|
discBottom.Rotation = discTop.Rotation / 3;
|
2020-07-30 11:05:19 +08:00
|
|
|
|
2020-11-05 17:00:26 +08:00
|
|
|
glow.Alpha = DrawableSpinner.Progress;
|
2020-09-28 16:46:22 +08:00
|
|
|
|
2020-11-05 18:05:59 +08:00
|
|
|
scaleContainer.Scale = new Vector2(SPRITE_SCALE * (0.8f + (float)Interpolation.ApplyEasing(Easing.Out, DrawableSpinner.Progress) * 0.2f));
|
2020-09-28 16:41:10 +08:00
|
|
|
}
|
2020-07-29 21:31:18 +08:00
|
|
|
}
|
|
|
|
}
|