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

@ -30,6 +30,22 @@ namespace osu.Game.Modes
public readonly BindableInt Combo = new BindableInt(); public readonly BindableInt Combo = new BindableInt();
/// <summary>
/// Are we allowed to fail?
/// </summary>
protected bool CanFail => true;
protected bool HasFailed;
/// <summary>
/// Called when we reach a failing health of zero.
/// </summary>
public event Action Failed;
/// <summary>
/// Keeps track of the highest combo ever achieved in this play.
/// This is handled automatically by ScoreProcessor.
/// </summary>
public readonly BindableInt HighestCombo = new BindableInt(); public readonly BindableInt HighestCombo = new BindableInt();
public readonly List<JudgementInfo> Judgements; public readonly List<JudgementInfo> Judgements;
@ -51,6 +67,11 @@ namespace osu.Game.Modes
UpdateCalculations(judgement); UpdateCalculations(judgement);
judgement.ComboAtHit = (ulong)Combo.Value; judgement.ComboAtHit = (ulong)Combo.Value;
if (Health.Value == Health.MinValue && !HasFailed)
{
HasFailed = true;
Failed?.Invoke();
}
} }
/// <summary> /// <summary>

View File

@ -63,7 +63,7 @@ namespace osu.Game.Modes.UI
processor.TotalScore.ValueChanged += delegate { ScoreCounter?.Set((ulong)processor.TotalScore.Value); }; processor.TotalScore.ValueChanged += delegate { ScoreCounter?.Set((ulong)processor.TotalScore.Value); };
processor.Accuracy.ValueChanged += delegate { AccuracyCounter?.Set((float)processor.Accuracy.Value); }; processor.Accuracy.ValueChanged += delegate { AccuracyCounter?.Set((float)processor.Accuracy.Value); };
processor.Combo.ValueChanged += delegate { ComboCounter?.Set((ulong)processor.Combo.Value); }; processor.Combo.ValueChanged += delegate { ComboCounter?.Set((ulong)processor.Combo.Value); };
if (HealthDisplay != null) processor.Health.Weld(HealthDisplay.Current); if (HealthDisplay != null) HealthDisplay.Current.Weld(processor.Health);
} }
} }
} }

View File

@ -0,0 +1,45 @@
//Copyright (c) 2007-2016 ppy Pty Ltd <contact@ppy.sh>.
//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using osu.Framework.GameModes;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.Transformations;
using osu.Game.Modes;
using osu.Game.Screens.Backgrounds;
using OpenTK;
using OpenTK.Graphics;
namespace osu.Game.Screens.Play
{
class FailDialog : OsuGameMode
{
protected override BackgroundMode CreateBackground() => new BackgroundModeBeatmap(Beatmap);
private static readonly Vector2 BACKGROUND_BLUR = new Vector2(20);
public FailDialog()
{
Add(new SpriteText
{
Text = "You failed!",
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
TextSize = 50
});
}
protected override void OnEntering(GameMode last)
{
base.OnEntering(last);
Background.Schedule(() => (Background as BackgroundModeBeatmap)?.BlurTo(BACKGROUND_BLUR, 1000));
}
protected override bool OnExiting(GameMode next)
{
Background.Schedule(() => Background.FadeColour(Color4.White, 500));
return base.OnExiting(next);
}
}
}

View File

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

View File

@ -116,6 +116,7 @@
<Compile Include="Screens\Multiplayer\Lobby.cs" /> <Compile Include="Screens\Multiplayer\Lobby.cs" />
<Compile Include="Screens\Multiplayer\Match.cs" /> <Compile Include="Screens\Multiplayer\Match.cs" />
<Compile Include="Screens\Multiplayer\MatchCreate.cs" /> <Compile Include="Screens\Multiplayer\MatchCreate.cs" />
<Compile Include="Screens\Play\FailDialog.cs" />
<Compile Include="Screens\Play\PlayerInputManager.cs" /> <Compile Include="Screens\Play\PlayerInputManager.cs" />
<Compile Include="Screens\Select\CarouselContainer.cs" /> <Compile Include="Screens\Select\CarouselContainer.cs" />
<Compile Include="Screens\Select\MatchSongSelect.cs" /> <Compile Include="Screens\Select\MatchSongSelect.cs" />