osu/osu.Game/Rulesets/Mods/ModEasy.cs

50 lines
2.1 KiB
C#
Raw Normal View History

// 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.
2018-04-13 09:19:50 +00:00
using System;
using osu.Framework.Graphics.Sprites;
2018-04-13 09:19:50 +00:00
using osu.Game.Beatmaps;
using osu.Game.Graphics;
2019-04-03 20:58:17 +00:00
using osu.Game.Rulesets.Scoring;
2018-04-13 09:19:50 +00:00
namespace osu.Game.Rulesets.Mods
{
2019-04-03 20:58:17 +00:00
public abstract class ModEasy : Mod, IApplicableToDifficulty, IApplicableToScoreProcessor
2018-04-13 09:19:50 +00:00
{
2019-04-04 21:04:49 +00:00
private int lives;
2018-04-13 09:19:50 +00:00
public override string Name => "Easy";
public override string Acronym => "EZ";
public override IconUsage Icon => OsuIcon.ModEasy;
2018-04-13 09:19:50 +00:00
public override ModType Type => ModType.DifficultyReduction;
public override double ScoreMultiplier => 0.5;
public override bool Ranked => true;
public override Type[] IncompatibleMods => new[] { typeof(ModHardRock) };
2019-04-04 21:04:49 +00:00
2018-04-13 09:19:50 +00:00
public void ApplyToDifficulty(BeatmapDifficulty difficulty)
{
const float ratio = 0.5f;
difficulty.CircleSize *= ratio;
difficulty.ApproachRate *= ratio;
difficulty.DrainRate *= ratio;
difficulty.OverallDifficulty *= ratio;
}
2019-04-03 20:58:17 +00:00
public void ApplyToScoreProcessor(ScoreProcessor scoreProcessor)
{
2019-04-04 16:21:53 +00:00
//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.
2019-04-04 21:04:49 +00:00
lives = 2;
2019-04-03 22:20:20 +00:00
scoreProcessor.Health.ValueChanged += valueChanged =>
{
2019-04-04 21:04:49 +00:00
if (scoreProcessor.Health.Value == scoreProcessor.Health.MinValue && lives > 0)
2019-04-03 20:58:17 +00:00
{
2019-04-04 21:04:49 +00:00
lives--;
2019-04-04 16:21:53 +00:00
scoreProcessor.Health.Value = scoreProcessor.Health.MaxValue;
2019-04-03 20:58:17 +00:00
}
2019-04-03 21:05:47 +00:00
};
2019-04-03 20:58:17 +00:00
}
2018-04-13 09:19:50 +00:00
}
}