From 3b3b1e51ee43953bf713768ac89cca5e3b6e2d31 Mon Sep 17 00:00:00 2001 From: David Zhao Date: Tue, 12 Mar 2019 19:41:33 +0900 Subject: [PATCH] Move hit animation logic into virtual method --- .../UI/DrawableManiaJudgement.cs | 15 ++++------- .../Rulesets/Judgements/DrawableJudgement.cs | 27 ++++++++++--------- 2 files changed, 19 insertions(+), 23 deletions(-) diff --git a/osu.Game.Rulesets.Mania/UI/DrawableManiaJudgement.cs b/osu.Game.Rulesets.Mania/UI/DrawableManiaJudgement.cs index 3073b1dd19..8797f014df 100644 --- a/osu.Game.Rulesets.Mania/UI/DrawableManiaJudgement.cs +++ b/osu.Game.Rulesets.Mania/UI/DrawableManiaJudgement.cs @@ -24,18 +24,13 @@ namespace osu.Game.Rulesets.Mania.UI protected override double FadeInDuration => 50; - protected override float InitialHitScale => 0.8f; - - protected override double HitFadeOutDuration => 200; - - protected override float HitScaleDuration => 250; - - protected override void LoadComplete() + protected override void ApplyHitAnimations() { - if (Result.IsHit) - JudgementBody.Delay(FadeInDuration).ScaleTo(0.75f, HitScaleDuration); + JudgementBody.ScaleTo(0.8f); + JudgementBody.ScaleTo(1, 250, Easing.OutElastic); - base.LoadComplete(); + JudgementBody.Delay(FadeInDuration).ScaleTo(0.75f, 250); + this.Delay(FadeInDuration).FadeOut(200); } } } diff --git a/osu.Game/Rulesets/Judgements/DrawableJudgement.cs b/osu.Game/Rulesets/Judgements/DrawableJudgement.cs index 308a2b00f9..16e7fd4a15 100644 --- a/osu.Game/Rulesets/Judgements/DrawableJudgement.cs +++ b/osu.Game/Rulesets/Judgements/DrawableJudgement.cs @@ -32,14 +32,12 @@ namespace osu.Game.Rulesets.Judgements protected Container JudgementBody; protected SpriteText JudgementText; + /// + /// The amount of time for this judgement to initially fade in. + /// + /// Override this to change fade in times of mode-specific judgements protected virtual double FadeInDuration => 100; - protected virtual float InitialHitScale => 0.9f; - - protected virtual float HitScaleDuration => 500; - - protected virtual double HitFadeOutDuration => 400; - /// /// Creates a drawable which visualises a . /// @@ -73,7 +71,13 @@ namespace osu.Game.Rulesets.Judgements }; } - private const double MISS_ANIMATION_DURATION = 800; + protected virtual void ApplyHitAnimations() + { + JudgementBody.ScaleTo(0.9f); + JudgementBody.ScaleTo(1, 500, Easing.OutElastic); + + this.Delay(FadeInDuration).FadeOut(400); + } protected override void LoadComplete() { @@ -89,16 +93,13 @@ namespace osu.Game.Rulesets.Judgements JudgementBody.ScaleTo(1.6f); JudgementBody.ScaleTo(1, FadeInDuration, Easing.In); - JudgementBody.MoveToOffset(new Vector2(0, 100), MISS_ANIMATION_DURATION, Easing.InQuint); - JudgementBody.RotateTo(40, MISS_ANIMATION_DURATION, Easing.InQuint); + JudgementBody.MoveToOffset(new Vector2(0, 100), 800, Easing.InQuint); + JudgementBody.RotateTo(40, 800, Easing.InQuint); this.Delay(600).FadeOut(200); break; default: - JudgementBody.ScaleTo(InitialHitScale); - JudgementBody.ScaleTo(1, HitScaleDuration, Easing.OutElastic); - - this.Delay(FadeInDuration).FadeOut(HitFadeOutDuration); + ApplyHitAnimations(); break; }