Changed the logic to ModEasy.

This commit is contained in:
RORIdev 2019-04-03 17:58:17 -03:00
parent 9cfe17cbf1
commit f6e1cb07a1
2 changed files with 25 additions and 24 deletions

View File

@ -5,11 +5,13 @@ using System;
using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Sprites;
using osu.Game.Beatmaps; using osu.Game.Beatmaps;
using osu.Game.Graphics; using osu.Game.Graphics;
using osu.Game.Rulesets.Scoring;
namespace osu.Game.Rulesets.Mods namespace osu.Game.Rulesets.Mods
{ {
public abstract class ModEasy : Mod, IApplicableToDifficulty public abstract class ModEasy : Mod, IApplicableToDifficulty, IApplicableToScoreProcessor
{ {
public static int Lives = 2;
public override string Name => "Easy"; public override string Name => "Easy";
public override string Acronym => "EZ"; public override string Acronym => "EZ";
public override IconUsage Icon => OsuIcon.ModEasy; public override IconUsage Icon => OsuIcon.ModEasy;
@ -26,5 +28,21 @@ namespace osu.Game.Rulesets.Mods
difficulty.DrainRate *= ratio; difficulty.DrainRate *= ratio;
difficulty.OverallDifficulty *= ratio; difficulty.OverallDifficulty *= ratio;
} }
public void ApplyToScoreProcessor(ScoreProcessor scoreProcessor)
{
scoreProcessor.Health.ValueChanged += ValueChanged =>{
if (scoreProcessor.Health.Value == 0)
{
if (Lives != 0)
{
Lives--;
scoreProcessor.Health.Value = 100;
}
}
} ;
}
} }
} }

View File

@ -325,38 +325,21 @@ namespace osu.Game.Screens.Play
protected FailOverlay FailOverlay { get; private set; } protected FailOverlay FailOverlay { get; private set; }
private void fail()
{
GameplayClockContainer.Stop();
HasFailed = true;
FailOverlay.Retries = RestartCount;
FailOverlay.Show();
}
private bool onFail() private bool onFail()
{ {
//issue #3372
if (Beatmap.Value.Mods.Value.Any(x => x is ModEasy))
{
if (Lives != 0)
{
Lives--;
ScoreProcessor.Health.Value = 100;
return false;
}
else
{
fail();
return true;
}
}
if (Beatmap.Value.Mods.Value.OfType<IApplicableFailOverride>().Any(m => !m.AllowFail)) if (Beatmap.Value.Mods.Value.OfType<IApplicableFailOverride>().Any(m => !m.AllowFail))
return false; 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) // There is a chance that we could be in a paused state as the ruleset's internal clock (see FrameStabilityContainer)
// could process an extra frame after the GameplayClock is stopped. // could process an extra frame after the GameplayClock is stopped.
// In such cases we want the fail state to precede a user triggered pause. // In such cases we want the fail state to precede a user triggered pause.
if (PauseOverlay.State == Visibility.Visible) if (PauseOverlay.State == Visibility.Visible)
PauseOverlay.Hide(); PauseOverlay.Hide();
fail(); FailOverlay.Retries = RestartCount;
FailOverlay.Show();
return true; return true;
} }