1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-22 11:27:24 +08:00
osu-lazer/osu.Game/Rulesets/Mods/ModEasy.cs
2019-04-04 18:04:49 -03:00

50 lines
2.1 KiB
C#

// 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;
using osu.Framework.Graphics.Sprites;
using osu.Game.Beatmaps;
using osu.Game.Graphics;
using osu.Game.Rulesets.Scoring;
namespace osu.Game.Rulesets.Mods
{
public abstract class ModEasy : Mod, IApplicableToDifficulty, IApplicableToScoreProcessor
{
private int lives;
public override string Name => "Easy";
public override string Acronym => "EZ";
public override IconUsage Icon => OsuIcon.ModEasy;
public override ModType Type => ModType.DifficultyReduction;
public override double ScoreMultiplier => 0.5;
public override bool Ranked => true;
public override Type[] IncompatibleMods => new[] { typeof(ModHardRock) };
public void ApplyToDifficulty(BeatmapDifficulty difficulty)
{
const float ratio = 0.5f;
difficulty.CircleSize *= ratio;
difficulty.ApproachRate *= ratio;
difficulty.DrainRate *= ratio;
difficulty.OverallDifficulty *= ratio;
}
public void ApplyToScoreProcessor(ScoreProcessor scoreProcessor)
{
//Note : The lives has to be instaciated here in order to prevent the values from different plays to interfear
//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;
}
};
}
}
}