From 66f3370a190b1ea8a0d647fb7007abcd96b4b75b Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 15 Oct 2021 19:14:59 +0900 Subject: [PATCH] Add new fail animation to better match new sound effects --- osu.Game/Screens/Play/FailAnimation.cs | 46 +++++++++-- osu.Game/Screens/Play/Player.cs | 102 +++++++++++++------------ 2 files changed, 95 insertions(+), 53 deletions(-) diff --git a/osu.Game/Screens/Play/FailAnimation.cs b/osu.Game/Screens/Play/FailAnimation.cs index 8c1f11718d..d4fc289991 100644 --- a/osu.Game/Screens/Play/FailAnimation.cs +++ b/osu.Game/Screens/Play/FailAnimation.cs @@ -12,6 +12,7 @@ using osu.Framework.Audio.Sample; using osu.Framework.Audio.Track; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Shapes; using osu.Framework.Utils; using osu.Game.Audio.Effects; using osu.Game.Beatmaps; @@ -25,14 +26,15 @@ namespace osu.Game.Screens.Play /// Manage the animation to be applied when a player fails. /// Single use and automatically disposed after use. /// - public class FailAnimation : CompositeDrawable + public class FailAnimation : Container { public Action OnComplete; private readonly DrawableRuleset drawableRuleset; - private readonly BindableDouble trackFreq = new BindableDouble(1); + private Box failFlash; + private Track track; private AudioFilter failLowPassFilter; @@ -42,9 +44,18 @@ namespace osu.Game.Screens.Play private Sample failSample; + protected override Container Content { get; } = new Container + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + RelativeSizeAxes = Axes.Both, + }; + public FailAnimation(DrawableRuleset drawableRuleset) { this.drawableRuleset = drawableRuleset; + + RelativeSizeAxes = Axes.Both; } [BackgroundDependencyLoader] @@ -53,8 +64,20 @@ namespace osu.Game.Screens.Play track = beatmap.Value.Track; failSample = audio.Samples.Get(@"Gameplay/failsound"); - AddInternal(failLowPassFilter = new AudioFilter(audio.TrackMixer)); - AddInternal(failHighPassFilter = new AudioFilter(audio.TrackMixer, BQFType.HighPass)); + AddRangeInternal(new Drawable[] + { + failLowPassFilter = new AudioFilter(audio.TrackMixer), + failHighPassFilter = new AudioFilter(audio.TrackMixer, BQFType.HighPass), + Content, + failFlash = new Box + { + Colour = Color4.Red, + RelativeSizeAxes = Axes.Both, + Blending = BlendingParameters.Additive, + Depth = float.MinValue, + Alpha = 0 + }, + }); } private bool started; @@ -81,8 +104,21 @@ namespace osu.Game.Screens.Play track.AddAdjustment(AdjustableProperty.Frequency, trackFreq); applyToPlayfield(drawableRuleset.Playfield); - drawableRuleset.Playfield.HitObjectContainer.FlashColour(Color4.Red, 500); drawableRuleset.Playfield.HitObjectContainer.FadeOut(duration / 2); + + failFlash.FadeOutFromOne(1000); + + Content.Masking = true; + + Content.Add(new Box + { + Colour = Color4.Black, + RelativeSizeAxes = Axes.Both, + Depth = float.MaxValue + }); + + Content.ScaleTo(0.85f, duration, Easing.OutQuint); + Content.RotateTo(1, duration, Easing.OutQuint); } protected override void Update() diff --git a/osu.Game/Screens/Play/Player.cs b/osu.Game/Screens/Play/Player.cs index 444bea049b..9199e8c247 100644 --- a/osu.Game/Screens/Play/Player.cs +++ b/osu.Game/Screens/Play/Player.cs @@ -339,54 +339,8 @@ namespace osu.Game.Screens.Play var container = new Container { RelativeSizeAxes = Axes.Both, - Children = new[] + Children = new Drawable[] { - DimmableStoryboard.OverlayLayerContainer.CreateProxy(), - BreakOverlay = new BreakOverlay(working.Beatmap.BeatmapInfo.LetterboxInBreaks, ScoreProcessor) - { - Clock = DrawableRuleset.FrameStableClock, - ProcessCustomClock = false, - Breaks = working.Beatmap.Breaks - }, - // display the cursor above some HUD elements. - DrawableRuleset.Cursor?.CreateProxy() ?? new Container(), - DrawableRuleset.ResumeOverlay?.CreateProxy() ?? new Container(), - HUDOverlay = new HUDOverlay(DrawableRuleset, GameplayState.Mods) - { - HoldToQuit = - { - Action = () => PerformExit(true), - IsPaused = { BindTarget = GameplayClockContainer.IsPaused } - }, - KeyCounter = - { - AlwaysVisible = { BindTarget = DrawableRuleset.HasReplayLoaded }, - IsCounting = false - }, - Anchor = Anchor.Centre, - Origin = Anchor.Centre - }, - skipIntroOverlay = new SkipOverlay(DrawableRuleset.GameplayStartTime) - { - RequestSkip = performUserRequestedSkip - }, - skipOutroOverlay = new SkipOverlay(Beatmap.Value.Storyboard.LatestEventTime ?? 0) - { - RequestSkip = () => progressToResults(false), - Alpha = 0 - }, - FailOverlay = new FailOverlay - { - OnRetry = Restart, - OnQuit = () => PerformExit(true), - }, - PauseOverlay = new PauseOverlay - { - OnResume = Resume, - Retries = RestartCount, - OnRetry = Restart, - OnQuit = () => PerformExit(true), - }, new HotkeyExitOverlay { Action = () => @@ -397,7 +351,59 @@ namespace osu.Game.Screens.Play PerformExit(false); }, }, - failAnimation = new FailAnimation(DrawableRuleset) { OnComplete = onFailComplete, }, + failAnimation = new FailAnimation(DrawableRuleset) + { + OnComplete = onFailComplete, + Children = new[] + { + DimmableStoryboard.OverlayLayerContainer.CreateProxy(), + BreakOverlay = new BreakOverlay(working.Beatmap.BeatmapInfo.LetterboxInBreaks, ScoreProcessor) + { + Clock = DrawableRuleset.FrameStableClock, + ProcessCustomClock = false, + Breaks = working.Beatmap.Breaks + }, + // display the cursor above some HUD elements. + DrawableRuleset.Cursor?.CreateProxy() ?? new Container(), + DrawableRuleset.ResumeOverlay?.CreateProxy() ?? new Container(), + HUDOverlay = new HUDOverlay(DrawableRuleset, GameplayState.Mods) + { + HoldToQuit = + { + Action = () => PerformExit(true), + IsPaused = { BindTarget = GameplayClockContainer.IsPaused } + }, + KeyCounter = + { + AlwaysVisible = { BindTarget = DrawableRuleset.HasReplayLoaded }, + IsCounting = false + }, + Anchor = Anchor.Centre, + Origin = Anchor.Centre + }, + skipIntroOverlay = new SkipOverlay(DrawableRuleset.GameplayStartTime) + { + RequestSkip = performUserRequestedSkip + }, + skipOutroOverlay = new SkipOverlay(Beatmap.Value.Storyboard.LatestEventTime ?? 0) + { + RequestSkip = () => progressToResults(false), + Alpha = 0 + }, + PauseOverlay = new PauseOverlay + { + OnResume = Resume, + Retries = RestartCount, + OnRetry = Restart, + OnQuit = () => PerformExit(true), + }, + } + }, + FailOverlay = new FailOverlay + { + OnRetry = Restart, + OnQuit = () => PerformExit(true), + } } };