Add fail dialog and flow.

This commit is contained in:
Dean Herbert
2017-01-20 15:51:43 +08:00
parent 1d24ad3db6
commit 139cac5e57
5 changed files with 89 additions and 6 deletions

View File

@ -24,6 +24,7 @@ using osu.Game.Screens.Ranking;
using osu.Game.Configuration;
using osu.Framework.Configuration;
using System;
using OpenTK.Graphics;
namespace osu.Game.Screens.Play
{
@ -31,12 +32,10 @@ namespace osu.Game.Screens.Play
{
public bool Autoplay;
protected override BackgroundMode CreateBackground() => null;
protected override BackgroundMode CreateBackground() => new BackgroundModeBeatmap(Beatmap);
internal override bool ShowOverlays => false;
protected bool CanFail => true;
public BeatmapInfo BeatmapInfo;
public PlayMode PreferredPlayMode;
@ -98,8 +97,12 @@ namespace osu.Game.Screens.Play
hitRenderer = ruleset.CreateHitRendererWith(beatmap.HitObjects);
//bind HitRenderer to ScoreProcessor and ourselves (for a pass situation)
hitRenderer.OnJudgement += scoreProcessor.AddJudgement;
hitRenderer.OnAllJudged += hitRenderer_OnAllJudged;
hitRenderer.OnAllJudged += onPass;
//bind ScoreProcessor to ourselves (for a fail situation)
scoreProcessor.Failed += onFail;
if (Autoplay)
hitRenderer.Schedule(() => hitRenderer.DrawableObjects.ForEach(h => h.State = ArmedState.Hit));
@ -134,7 +137,7 @@ namespace osu.Game.Screens.Play
});
}
private void hitRenderer_OnAllJudged()
private void onPass()
{
Delay(1000);
Schedule(delegate
@ -147,6 +150,19 @@ namespace osu.Game.Screens.Play
});
}
private void onFail()
{
Content.FadeColour(Color4.Red, 500);
sourceClock.Stop();
Delay(500);
Schedule(delegate
{
ValidForResume = false;
Push(new FailDialog());
});
}
protected override void OnEntering(GameMode last)
{
base.OnEntering(last);