1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-27 02:32:59 +08:00

Add health drain to catch

This commit is contained in:
clayton 2018-06-09 17:39:17 -07:00
parent f486bcfee1
commit 808118e4d4
No known key found for this signature in database
GPG Key ID: 27E0498D54E725EB
6 changed files with 78 additions and 1 deletions

View File

@ -20,5 +20,16 @@ namespace osu.Game.Rulesets.Catch.Judgements
return 1100;
}
}
protected override float HealthIncreaseFor(HitResult result)
{
switch (result)
{
default:
return 0;
case HitResult.Perfect:
return 8;
}
}
}
}

View File

@ -16,5 +16,6 @@ namespace osu.Game.Rulesets.Catch.Judgements
}
protected override int NumericResultFor(HitResult result) => 0;
protected override float HealthIncreaseFor(HitResult result) => 0;
}
}

View File

@ -18,5 +18,16 @@ namespace osu.Game.Rulesets.Catch.Judgements
return 30;
}
}
protected override float HealthIncreaseFor(HitResult result)
{
switch (result)
{
default:
return 0;
case HitResult.Perfect:
return 7;
}
}
}
}

View File

@ -25,5 +25,26 @@ namespace osu.Game.Rulesets.Catch.Judgements
return 300;
}
}
/// <summary>
/// The base health increase for the result achieved.
/// </summary>
public float HealthIncrease => HealthIncreaseFor(Result);
/// <summary>
/// Convert a <see cref="HitResult"/> to a base health increase.
/// </summary>
/// <param name="result">The value to convert.</param>
/// <returns>The base health increase.</returns>
protected virtual float HealthIncreaseFor(HitResult result)
{
switch (result)
{
default:
return 0;
case HitResult.Perfect:
return 10.2f;
}
}
}
}

View File

@ -20,5 +20,16 @@ namespace osu.Game.Rulesets.Catch.Judgements
return 10;
}
}
protected override float HealthIncreaseFor(HitResult result)
{
switch (result)
{
default:
return 0;
case HitResult.Perfect:
return 4;
}
}
}
}

View File

@ -1,10 +1,12 @@
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System;
using System.Linq;
using osu.Game.Beatmaps;
using osu.Game.Rulesets.Catch.Judgements;
using osu.Game.Rulesets.Catch.Objects;
using osu.Game.Rulesets.Judgements;
using osu.Game.Rulesets.Scoring;
using osu.Game.Rulesets.UI;
@ -17,8 +19,12 @@ namespace osu.Game.Rulesets.Catch.Scoring
{
}
private float hpDrainRate;
protected override void SimulateAutoplay(Beatmap<CatchHitObject> beatmap)
{
hpDrainRate = beatmap.BeatmapInfo.BaseDifficulty.DrainRate;
foreach (var obj in beatmap.HitObjects)
{
switch (obj)
@ -47,8 +53,24 @@ namespace osu.Game.Rulesets.Catch.Scoring
break;
}
}
}
base.SimulateAutoplay(beatmap);
private const double harshness = 0.01;
protected override void OnNewJudgement(Judgement judgement)
{
base.OnNewJudgement(judgement);
if (judgement.Result == HitResult.Miss)
{
if (judgement.AffectsCombo)
Health.Value -= hpDrainRate * (harshness * 2);
return;
}
var catchJudgement = judgement as CatchJudgement;
Health.Value += Math.Max(catchJudgement.HealthIncrease - hpDrainRate, 0) * harshness;
}
}
}