2022-12-11 09:17:50 +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.Graphics;
|
|
|
|
|
using osu.Framework.Allocation;
|
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
|
using osu.Game.Skinning;
|
|
|
|
|
using osu.Framework.Graphics.Sprites;
|
|
|
|
|
using osu.Game.Rulesets.Taiko.Objects.Drawables;
|
|
|
|
|
using osu.Game.Rulesets.Taiko.Objects;
|
|
|
|
|
using osu.Framework.Audio.Sample;
|
|
|
|
|
using osu.Game.Audio;
|
|
|
|
|
using osuTK;
|
|
|
|
|
using osu.Game.Rulesets.Objects.Drawables;
|
2025-01-31 17:51:35 +08:00
|
|
|
|
using osu.Framework.Extensions.ObjectExtensions;
|
2022-12-11 09:17:50 +08:00
|
|
|
|
|
|
|
|
|
namespace osu.Game.Rulesets.Taiko.Skinning.Legacy
|
|
|
|
|
{
|
2025-01-31 17:51:35 +08:00
|
|
|
|
public partial class LegacySwell : Container
|
2022-12-11 09:17:50 +08:00
|
|
|
|
{
|
2025-01-31 17:51:35 +08:00
|
|
|
|
private DrawableSwell drawableSwell = null!;
|
|
|
|
|
|
2022-12-11 09:17:50 +08:00
|
|
|
|
private Container bodyContainer = null!;
|
2025-01-31 16:55:39 +08:00
|
|
|
|
private Sprite warning = null!;
|
2022-12-11 09:17:50 +08:00
|
|
|
|
private Sprite spinnerCircle = null!;
|
|
|
|
|
private Sprite shrinkingRing = null!;
|
|
|
|
|
private Sprite clearAnimation = null!;
|
|
|
|
|
private ISample? clearSample;
|
|
|
|
|
private LegacySpriteText remainingHitsCountdown = null!;
|
|
|
|
|
|
|
|
|
|
private bool samplePlayed;
|
|
|
|
|
|
|
|
|
|
public LegacySwell()
|
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.Centre;
|
|
|
|
|
Origin = Anchor.Centre;
|
|
|
|
|
RelativeSizeAxes = Axes.Both;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
2025-01-31 17:51:35 +08:00
|
|
|
|
private void load(DrawableHitObject hitObject, ISkinSource skin, SkinManager skinManager)
|
2022-12-11 09:17:50 +08:00
|
|
|
|
{
|
|
|
|
|
Child = new Container
|
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
|
|
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
2025-01-31 16:55:39 +08:00
|
|
|
|
warning = new Sprite
|
|
|
|
|
{
|
|
|
|
|
Texture = skin.GetTexture("spinner-warning") ?? skinManager.DefaultClassicSkin.GetTexture("spinner-circle"),
|
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
|
Scale = skin.GetTexture("spinner-warning") != null ? Vector2.One : new Vector2(0.18f),
|
|
|
|
|
},
|
2022-12-11 09:17:50 +08:00
|
|
|
|
bodyContainer = new Container
|
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
|
Origin = Anchor.Centre,
|
2025-01-31 16:55:39 +08:00
|
|
|
|
Position = new Vector2(200f, 100f),
|
2022-12-11 09:17:50 +08:00
|
|
|
|
Alpha = 0,
|
|
|
|
|
|
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
|
|
|
|
spinnerCircle = new Sprite
|
|
|
|
|
{
|
|
|
|
|
Texture = skin.GetTexture("spinner-circle"),
|
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
|
Scale = new Vector2(0.8f),
|
|
|
|
|
},
|
|
|
|
|
shrinkingRing = new Sprite
|
|
|
|
|
{
|
|
|
|
|
Texture = skin.GetTexture("spinner-approachcircle") ?? skinManager.DefaultClassicSkin.GetTexture("spinner-approachcircle"),
|
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
|
Scale = Vector2.One,
|
|
|
|
|
},
|
|
|
|
|
remainingHitsCountdown = new LegacySpriteText(LegacyFont.Combo)
|
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
|
Position = new Vector2(0f, 165f),
|
|
|
|
|
Scale = Vector2.One,
|
|
|
|
|
},
|
2025-01-31 16:55:39 +08:00
|
|
|
|
clearAnimation = new Sprite
|
|
|
|
|
{
|
2025-01-31 18:52:19 +08:00
|
|
|
|
Texture = skin.GetTexture("spinner-osu"),
|
2025-01-31 16:55:39 +08:00
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
|
Position = new Vector2(0f, -165f),
|
|
|
|
|
Scale = new Vector2(0.3f),
|
|
|
|
|
Alpha = 0,
|
|
|
|
|
},
|
2022-12-11 09:17:50 +08:00
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
2025-01-31 17:51:35 +08:00
|
|
|
|
drawableSwell = (DrawableSwell)hitObject;
|
|
|
|
|
drawableSwell.UpdateHitProgress += animateSwellProgress;
|
|
|
|
|
drawableSwell.ApplyCustomUpdateState += updateStateTransforms;
|
2022-12-11 09:17:50 +08:00
|
|
|
|
clearSample = skin.GetSample(new SampleInfo("spinner-osu"));
|
|
|
|
|
}
|
|
|
|
|
|
2025-01-31 17:51:35 +08:00
|
|
|
|
private void animateSwellProgress(int numHits, int requiredHits)
|
2022-12-11 09:17:50 +08:00
|
|
|
|
{
|
2025-01-31 17:51:35 +08:00
|
|
|
|
remainingHitsCountdown.Text = $"{requiredHits - numHits}";
|
2022-12-11 09:17:50 +08:00
|
|
|
|
spinnerCircle.RotateTo(180f * numHits, 1000, Easing.OutQuint);
|
|
|
|
|
}
|
|
|
|
|
|
2025-01-31 17:51:35 +08:00
|
|
|
|
private void updateStateTransforms(DrawableHitObject drawableHitObject, ArmedState state)
|
2022-12-11 09:17:50 +08:00
|
|
|
|
{
|
2025-01-31 17:51:35 +08:00
|
|
|
|
if (!(drawableHitObject is DrawableSwell drawableSwell))
|
|
|
|
|
return;
|
2022-12-11 09:17:50 +08:00
|
|
|
|
|
2025-01-31 17:51:35 +08:00
|
|
|
|
Swell swell = drawableSwell.HitObject;
|
2022-12-11 09:17:50 +08:00
|
|
|
|
|
2025-01-31 17:51:35 +08:00
|
|
|
|
using (BeginAbsoluteSequence(swell.StartTime))
|
2022-12-11 09:17:50 +08:00
|
|
|
|
{
|
2025-01-31 17:51:35 +08:00
|
|
|
|
if (state == ArmedState.Idle)
|
2022-12-11 09:17:50 +08:00
|
|
|
|
{
|
2025-01-31 17:51:35 +08:00
|
|
|
|
remainingHitsCountdown.Text = $"{swell.RequiredHits}";
|
|
|
|
|
samplePlayed = false;
|
2022-12-11 09:17:50 +08:00
|
|
|
|
}
|
|
|
|
|
|
2025-01-31 17:51:35 +08:00
|
|
|
|
const double body_transition_duration = 100;
|
|
|
|
|
|
|
|
|
|
warning.FadeOut(body_transition_duration);
|
|
|
|
|
bodyContainer.FadeIn(body_transition_duration);
|
|
|
|
|
shrinkingRing.ResizeTo(0.1f, swell.Duration);
|
2022-12-11 09:17:50 +08:00
|
|
|
|
}
|
|
|
|
|
|
2025-01-31 17:51:35 +08:00
|
|
|
|
using (BeginAbsoluteSequence(drawableSwell.HitStateUpdateTime))
|
2022-12-11 09:17:50 +08:00
|
|
|
|
{
|
2025-01-31 17:51:35 +08:00
|
|
|
|
const double clear_transition_duration = 300;
|
|
|
|
|
|
|
|
|
|
bodyContainer.FadeOut(clear_transition_duration, Easing.OutQuad);
|
|
|
|
|
|
|
|
|
|
if (state == ArmedState.Hit)
|
|
|
|
|
{
|
|
|
|
|
if (!samplePlayed)
|
|
|
|
|
{
|
|
|
|
|
clearSample?.Play();
|
|
|
|
|
samplePlayed = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
clearAnimation
|
|
|
|
|
.FadeIn(clear_transition_duration, Easing.InQuad)
|
|
|
|
|
.ScaleTo(0.8f, clear_transition_duration, Easing.InQuad)
|
|
|
|
|
.Delay(700).FadeOut(200, Easing.OutQuad);
|
|
|
|
|
}
|
2022-12-11 09:17:50 +08:00
|
|
|
|
}
|
2025-01-31 17:51:35 +08:00
|
|
|
|
}
|
2022-12-11 09:17:50 +08:00
|
|
|
|
|
2025-01-31 17:51:35 +08:00
|
|
|
|
protected override void Dispose(bool isDisposing)
|
|
|
|
|
{
|
|
|
|
|
base.Dispose(isDisposing);
|
2022-12-11 09:17:50 +08:00
|
|
|
|
|
2025-01-31 17:51:35 +08:00
|
|
|
|
if (drawableSwell.IsNotNull())
|
|
|
|
|
{
|
|
|
|
|
drawableSwell.UpdateHitProgress -= animateSwellProgress;
|
|
|
|
|
drawableSwell.ApplyCustomUpdateState -= updateStateTransforms;
|
|
|
|
|
}
|
2022-12-11 09:17:50 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|