From ebc75d40d2a7478950ba3e5544ef5dcb19346bdf Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 2 Dec 2022 17:32:57 +0900 Subject: [PATCH] Switch to using immediate transforms to make rewind handle better --- .../Skinning/Legacy/LegacyKiaiGlow.cs | 40 ++++++++++--------- 1 file changed, 22 insertions(+), 18 deletions(-) diff --git a/osu.Game.Rulesets.Taiko/Skinning/Legacy/LegacyKiaiGlow.cs b/osu.Game.Rulesets.Taiko/Skinning/Legacy/LegacyKiaiGlow.cs index d06571eba2..623243e9e1 100644 --- a/osu.Game.Rulesets.Taiko/Skinning/Legacy/LegacyKiaiGlow.cs +++ b/osu.Game.Rulesets.Taiko/Skinning/Legacy/LegacyKiaiGlow.cs @@ -1,6 +1,7 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. +using System; using osu.Framework.Allocation; using osu.Framework.Audio.Track; using osu.Framework.Graphics; @@ -18,16 +19,17 @@ internal partial class LegacyKiaiGlow : BeatSyncedContainer { private bool isKiaiActive; + private Sprite sprite = null!; + [BackgroundDependencyLoader(true)] private void load(ISkinSource skin, HealthProcessor? healthProcessor) { - Alpha = 0; - - Child = new Sprite + Child = sprite = new Sprite { Texture = skin.GetTexture("taiko-glow"), Origin = Anchor.Centre, Anchor = Anchor.Centre, + Alpha = 0, Scale = new Vector2(0.7f), Colour = new Colour4(255, 228, 0, 255), }; @@ -36,26 +38,28 @@ private void load(ISkinSource skin, HealthProcessor? healthProcessor) healthProcessor.NewJudgement += onNewJudgement; } + protected override void Update() + { + base.Update(); + + if (isKiaiActive) + sprite.Alpha = (float)Math.Min(1, sprite.Alpha + Math.Abs(Clock.ElapsedFrameTime) / 100f); + else + sprite.Alpha = (float)Math.Max(0, sprite.Alpha - Math.Abs(Clock.ElapsedFrameTime) / 600f); + } + + protected override void OnNewBeat(int beatIndex, TimingControlPoint timingPoint, EffectControlPoint effectPoint, ChannelAmplitudes amplitudes) + { + isKiaiActive = effectPoint.KiaiMode; + } + private void onNewJudgement(JudgementResult result) { if (!result.IsHit || !isKiaiActive) return; - this.ScaleTo(1.2f).Then() - .ScaleTo(1f, 80, Easing.OutQuad); - } - - protected override void OnNewBeat(int beatIndex, TimingControlPoint timingPoint, EffectControlPoint effectPoint, ChannelAmplitudes amplitudes) - { - if (effectPoint.KiaiMode == isKiaiActive) - return; - - isKiaiActive = effectPoint.KiaiMode; - - if (isKiaiActive) - this.FadeIn(180); - else - this.FadeOut(180); + sprite.ScaleTo(0.85f).Then() + .ScaleTo(0.7f, 80, Easing.OutQuad); } } }