1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-18 05:52:55 +08:00
osu-lazer/osu.Game.Rulesets.Mania/Scoring/ManiaScoreProcessor.cs

175 lines
5.8 KiB
C#
Raw Normal View History

// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System.Linq;
2017-05-26 18:56:50 +08:00
using osu.Game.Beatmaps;
using osu.Game.Rulesets.Judgements;
2017-04-18 15:05:58 +08:00
using osu.Game.Rulesets.Mania.Judgements;
using osu.Game.Rulesets.Mania.Objects;
2017-05-26 18:56:50 +08:00
using osu.Game.Rulesets.Objects.Drawables;
2017-04-18 15:05:58 +08:00
using osu.Game.Rulesets.Scoring;
using osu.Game.Rulesets.UI;
2017-04-18 15:05:58 +08:00
namespace osu.Game.Rulesets.Mania.Scoring
{
2017-09-06 17:05:51 +08:00
internal class ManiaScoreProcessor : ScoreProcessor<ManiaHitObject>
{
2017-05-26 19:42:03 +08:00
/// <summary>
/// The hit HP multiplier at OD = 0.
/// </summary>
private const double hp_multiplier_min = 0.75;
/// <summary>
/// The hit HP multiplier at OD = 0.
/// </summary>
private const double hp_multiplier_mid = 0.85;
/// <summary>
/// The hit HP multiplier at OD = 0.
/// </summary>
private const double hp_multiplier_max = 1;
/// <summary>
/// The default BAD hit HP increase.
/// </summary>
private const double hp_increase_bad = 0.005;
/// <summary>
/// The default OK hit HP increase.
/// </summary>
private const double hp_increase_ok = 0.010;
/// <summary>
/// The default GOOD hit HP increase.
/// </summary>
private const double hp_increase_good = 0.035;
/// <summary>
/// The default tick hit HP increase.
/// </summary>
private const double hp_increase_tick = 0.040;
/// <summary>
/// The default GREAT hit HP increase.
/// </summary>
private const double hp_increase_great = 0.055;
/// <summary>
/// The default PERFECT hit HP increase.
/// </summary>
private const double hp_increase_perfect = 0.065;
/// <summary>
/// The MISS HP multiplier at OD = 0.
/// </summary>
private const double hp_multiplier_miss_min = 0.5;
/// <summary>
/// The MISS HP multiplier at OD = 5.
/// </summary>
private const double hp_multiplier_miss_mid = 0.75;
/// <summary>
/// The MISS HP multiplier at OD = 10.
/// </summary>
private const double hp_multiplier_miss_max = 1;
/// <summary>
/// The default MISS HP increase.
/// </summary>
private const double hp_increase_miss = -0.125;
2017-05-29 10:42:43 +08:00
/// <summary>
/// The MISS HP multiplier. This is multiplied to the miss hp increase.
/// </summary>
private double hpMissMultiplier = 1;
/// <summary>
/// The HIT HP multiplier. This is multiplied to hit hp increases.
/// </summary>
private double hpMultiplier = 1;
public ManiaScoreProcessor()
{
}
2017-09-06 17:05:51 +08:00
public ManiaScoreProcessor(RulesetContainer<ManiaHitObject> rulesetContainer)
2017-08-09 12:28:29 +08:00
: base(rulesetContainer)
{
}
protected override void SimulateAutoplay(Beatmap<ManiaHitObject> beatmap)
2017-05-26 18:56:50 +08:00
{
2017-05-26 19:42:03 +08:00
BeatmapDifficulty difficulty = beatmap.BeatmapInfo.Difficulty;
hpMultiplier = BeatmapDifficulty.DifficultyRange(difficulty.DrainRate, hp_multiplier_min, hp_multiplier_mid, hp_multiplier_max);
hpMissMultiplier = BeatmapDifficulty.DifficultyRange(difficulty.DrainRate, hp_multiplier_miss_min, hp_multiplier_miss_mid, hp_multiplier_miss_max);
2017-05-26 19:26:26 +08:00
while (true)
2017-05-26 18:56:50 +08:00
{
2017-05-26 19:26:26 +08:00
foreach (var obj in beatmap.HitObjects)
2017-05-26 18:56:50 +08:00
{
var holdNote = obj as HoldNote;
if (holdNote != null)
2017-05-26 18:56:50 +08:00
{
2017-05-26 19:26:26 +08:00
// Head
2017-09-05 18:44:59 +08:00
AddJudgement(new ManiaJudgement { Result = HitResult.Perfect });
2017-05-26 18:56:50 +08:00
2017-05-26 19:26:26 +08:00
// Ticks
int tickCount = holdNote.Ticks.Count();
for (int i = 0; i < tickCount; i++)
2017-09-05 18:44:59 +08:00
AddJudgement(new HoldNoteTickJudgement { Result = HitResult.Perfect });
2017-05-26 18:56:50 +08:00
}
AddJudgement(new ManiaJudgement { Result = HitResult.Perfect });
2017-05-26 18:56:50 +08:00
}
2017-05-26 19:26:26 +08:00
if (!HasFailed)
break;
hpMultiplier *= 1.01;
hpMissMultiplier *= 0.98;
Reset(false);
2017-05-26 18:56:50 +08:00
}
}
protected override void OnNewJudgement(Judgement judgement)
{
base.OnNewJudgement(judgement);
2017-05-26 18:56:50 +08:00
bool isTick = judgement is HoldNoteTickJudgement;
2017-09-05 18:44:59 +08:00
if (isTick)
{
if (judgement.IsHit)
Health.Value += hpMultiplier * hp_increase_tick;
}
else
{
switch (judgement.Result)
{
case HitResult.Miss:
Health.Value += hpMissMultiplier * hp_increase_miss;
break;
case HitResult.Meh:
Health.Value += hpMultiplier * hp_increase_bad;
break;
case HitResult.Ok:
Health.Value += hpMultiplier * hp_increase_ok;
break;
case HitResult.Good:
Health.Value += hpMultiplier * hp_increase_good;
break;
case HitResult.Great:
Health.Value += hpMultiplier * hp_increase_great;
break;
case HitResult.Perfect:
Health.Value += hpMultiplier * hp_increase_perfect;
break;
}
2017-05-26 18:56:50 +08:00
}
2017-05-22 14:28:51 +08:00
}
}
}