From f3fa39f2541c640398b2d312d167acd26b647386 Mon Sep 17 00:00:00 2001 From: Joppe27 Date: Wed, 30 Nov 2022 00:44:20 +0100 Subject: [PATCH] Add legacy taiko kiai glow element --- .../Skinning/Legacy/LegacyKiaiGlow.cs | 67 +++++++++++++++++++ .../Legacy/TaikoLegacySkinTransformer.cs | 6 ++ .../TaikoSkinComponents.cs | 1 + osu.Game.Rulesets.Taiko/UI/TaikoPlayfield.cs | 4 ++ 4 files changed, 78 insertions(+) create mode 100644 osu.Game.Rulesets.Taiko/Skinning/Legacy/LegacyKiaiGlow.cs diff --git a/osu.Game.Rulesets.Taiko/Skinning/Legacy/LegacyKiaiGlow.cs b/osu.Game.Rulesets.Taiko/Skinning/Legacy/LegacyKiaiGlow.cs new file mode 100644 index 0000000000..07eb052b20 --- /dev/null +++ b/osu.Game.Rulesets.Taiko/Skinning/Legacy/LegacyKiaiGlow.cs @@ -0,0 +1,67 @@ +// Copyright (c) ppy Pty Ltd . 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; +using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Sprites; +using osu.Game.Beatmaps; +using osu.Game.Rulesets.Judgements; +using osu.Game.Rulesets.Scoring; +using osu.Game.Skinning; +using osuTK; + +namespace osu.Game.Rulesets.Taiko.Skinning.Legacy +{ + internal partial class LegacyKiaiGlow : Container + { + public LegacyKiaiGlow() + { + AlwaysPresent = true; + Alpha = 0; + } + + [BackgroundDependencyLoader] + private void load(ISkinSource skin) + { + Child = new Sprite + { + Texture = skin.GetTexture("taiko-glow"), + Origin = Anchor.Centre, + Anchor = Anchor.Centre, + Scale = new Vector2(0.75f), + }; + } + + [Resolved(CanBeNull = true)] + private IBeatSyncProvider? beatSyncProvider { get; set; } + + [Resolved(CanBeNull = true)] + private HealthProcessor? healthProcessor { get; set; } + + protected override void Update() + { + base.Update(); + + if (healthProcessor != null) + healthProcessor.NewJudgement += onNewJudgement; + + if (beatSyncProvider != null) + { + if (beatSyncProvider.CheckIsKiaiTime()) + this.FadeIn(180); + else + this.FadeOut(180); + } + } + + private void onNewJudgement(JudgementResult result) + { + if (!result.IsHit) + return; + + this.ScaleTo(1.1f, 50) + .Then().ScaleTo(1f, 50); + } + } +} diff --git a/osu.Game.Rulesets.Taiko/Skinning/Legacy/TaikoLegacySkinTransformer.cs b/osu.Game.Rulesets.Taiko/Skinning/Legacy/TaikoLegacySkinTransformer.cs index 7bf99306f0..d61f9ac35d 100644 --- a/osu.Game.Rulesets.Taiko/Skinning/Legacy/TaikoLegacySkinTransformer.cs +++ b/osu.Game.Rulesets.Taiko/Skinning/Legacy/TaikoLegacySkinTransformer.cs @@ -129,6 +129,12 @@ namespace osu.Game.Rulesets.Taiko.Skinning.Legacy case TaikoSkinComponents.Mascot: return new DrawableTaikoMascot(); + case TaikoSkinComponents.KiaiGlow: + if (GetTexture("taiko-glow") != null) + return new LegacyKiaiGlow(); + + return null; + default: throw new UnsupportedSkinComponentException(lookup); } diff --git a/osu.Game.Rulesets.Taiko/TaikoSkinComponents.cs b/osu.Game.Rulesets.Taiko/TaikoSkinComponents.cs index bf48898dd2..b8e3313e1b 100644 --- a/osu.Game.Rulesets.Taiko/TaikoSkinComponents.cs +++ b/osu.Game.Rulesets.Taiko/TaikoSkinComponents.cs @@ -21,5 +21,6 @@ namespace osu.Game.Rulesets.Taiko TaikoExplosionKiai, Scroller, Mascot, + KiaiGlow } } diff --git a/osu.Game.Rulesets.Taiko/UI/TaikoPlayfield.cs b/osu.Game.Rulesets.Taiko/UI/TaikoPlayfield.cs index 6ce0be5868..9493de624a 100644 --- a/osu.Game.Rulesets.Taiko/UI/TaikoPlayfield.cs +++ b/osu.Game.Rulesets.Taiko/UI/TaikoPlayfield.cs @@ -112,6 +112,10 @@ namespace osu.Game.Rulesets.Taiko.UI FillMode = FillMode.Fit, Children = new[] { + new SkinnableDrawable(new TaikoSkinComponentLookup(TaikoSkinComponents.KiaiGlow), _ => Empty()) + { + RelativeSizeAxes = Axes.Both, + }, hitExplosionContainer = new Container { RelativeSizeAxes = Axes.Both,