mirror of
https://github.com/ppy/osu
synced 2024-12-25 00:02:48 +00:00
Bring up-to-date and use IApplicableFailOverride
This commit is contained in:
parent
4c4b71eeec
commit
c99b48f934
@ -2,16 +2,17 @@
|
|||||||
// See the LICENCE file in the repository root for full licence text.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
using osu.Framework.Bindables;
|
||||||
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;
|
using osu.Game.Rulesets.Scoring;
|
||||||
|
using osu.Game.Scoring;
|
||||||
|
|
||||||
namespace osu.Game.Rulesets.Mods
|
namespace osu.Game.Rulesets.Mods
|
||||||
{
|
{
|
||||||
public abstract class ModEasy : Mod, IApplicableToDifficulty, IApplicableToScoreProcessor
|
public abstract class ModEasy : Mod, IApplicableToDifficulty, IApplicableFailOverride, IApplicableToScoreProcessor
|
||||||
{
|
{
|
||||||
private int lives;
|
|
||||||
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;
|
||||||
@ -20,6 +21,10 @@ namespace osu.Game.Rulesets.Mods
|
|||||||
public override bool Ranked => true;
|
public override bool Ranked => true;
|
||||||
public override Type[] IncompatibleMods => new[] { typeof(ModHardRock) };
|
public override Type[] IncompatibleMods => new[] { typeof(ModHardRock) };
|
||||||
|
|
||||||
|
private int retries = 2;
|
||||||
|
|
||||||
|
private BindableNumber<double> health;
|
||||||
|
|
||||||
public void ApplyToDifficulty(BeatmapDifficulty difficulty)
|
public void ApplyToDifficulty(BeatmapDifficulty difficulty)
|
||||||
{
|
{
|
||||||
const float ratio = 0.5f;
|
const float ratio = 0.5f;
|
||||||
@ -29,21 +34,26 @@ namespace osu.Game.Rulesets.Mods
|
|||||||
difficulty.OverallDifficulty *= ratio;
|
difficulty.OverallDifficulty *= ratio;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool AllowFail
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (retries == 0) return true;
|
||||||
|
|
||||||
|
health.Value = health.MaxValue;
|
||||||
|
retries--;
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool RestartOnFail => false;
|
||||||
|
|
||||||
public void ApplyToScoreProcessor(ScoreProcessor scoreProcessor)
|
public void ApplyToScoreProcessor(ScoreProcessor scoreProcessor)
|
||||||
{
|
{
|
||||||
//Note : The lives has to be instaciated here in order to prevent the values from different plays to interfear
|
health = scoreProcessor.Health.GetBoundCopy();
|
||||||
//with each other / not reseting after a restart , as this method is called once a play starts (to my knowlegde).
|
|
||||||
//This will be better implemented with a List<double> once I know how to reliably get the game time and update it.
|
|
||||||
//If you know any information about that, please contact me because I didn't find a sollution to that.
|
|
||||||
lives = 2;
|
|
||||||
scoreProcessor.Health.ValueChanged += valueChanged =>
|
|
||||||
{
|
|
||||||
if (scoreProcessor.Health.Value == scoreProcessor.Health.MinValue && lives > 0)
|
|
||||||
{
|
|
||||||
lives--;
|
|
||||||
scoreProcessor.Health.Value = scoreProcessor.Health.MaxValue;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ScoreRank AdjustRank(ScoreRank rank, double accuracy) => rank;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user