Add animation on failing

This commit is contained in:
Dean Herbert
2019-06-04 16:13:16 +09:00
parent 76474987ef
commit 9c214c3f0e
5 changed files with 191 additions and 7 deletions

View File

@ -1,4 +1,4 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// 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 System;
@ -173,7 +173,8 @@ namespace osu.Game.Screens.Play
fadeOut(true);
Restart();
},
}
},
failAnimation = new FailAnimation(DrawableRuleset) { OnComplete = onFailComplete, }
};
DrawableRuleset.HasReplayLoaded.BindValueChanged(e => HUDOverlay.HoldToQuit.PauseOnFocusLost = !e.NewValue && PauseOnFocusLost, true);
@ -345,13 +346,13 @@ namespace osu.Game.Screens.Play
protected FailOverlay FailOverlay { get; private set; }
private FailAnimation failAnimation;
private bool onFail()
{
if (Mods.Value.OfType<IApplicableFailOverride>().Any(m => !m.AllowFail))
return false;
GameplayClockContainer.Stop();
HasFailed = true;
// There is a chance that we could be in a paused state as the ruleset's internal clock (see FrameStabilityContainer)
@ -360,9 +361,17 @@ namespace osu.Game.Screens.Play
if (PauseOverlay.State == Visibility.Visible)
PauseOverlay.Hide();
failAnimation.Start();
return true;
}
// Called back when the transform finishes
private void onFailComplete()
{
GameplayClockContainer.Stop();
FailOverlay.Retries = RestartCount;
FailOverlay.Show();
return true;
}
#endregion
@ -489,6 +498,13 @@ namespace osu.Game.Screens.Play
// still want to block if we are within the cooldown period and not already paused.
return true;
if (HasFailed && ValidForResume && !FailOverlay.IsPresent)
// ValidForResume is false when restarting
{
failAnimation.FinishTransforms(true);
return true;
}
GameplayClockContainer.ResetLocalAdjustments();
fadeOut();