mirror of
https://github.com/ppy/osu.git
synced 2025-02-20 09:03:00 +08:00
Make Rulesets.Catch use the new judgement result structure
This commit is contained in:
parent
807794d512
commit
9dff5cea07
@ -1,6 +1,7 @@
|
||||
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using osu.Game.Rulesets.Judgements;
|
||||
using osu.Game.Rulesets.Scoring;
|
||||
|
||||
namespace osu.Game.Rulesets.Catch.Judgements
|
||||
@ -9,8 +10,6 @@ namespace osu.Game.Rulesets.Catch.Judgements
|
||||
{
|
||||
public override bool AffectsCombo => false;
|
||||
|
||||
public override bool ShouldExplode => true;
|
||||
|
||||
protected override int NumericResultFor(HitResult result)
|
||||
{
|
||||
switch (result)
|
||||
@ -32,5 +31,7 @@ namespace osu.Game.Rulesets.Catch.Judgements
|
||||
return 8;
|
||||
}
|
||||
}
|
||||
|
||||
public override bool ShouldExplodeFor(JudgementResult result) => true;
|
||||
}
|
||||
}
|
||||
|
@ -23,21 +23,10 @@ namespace osu.Game.Rulesets.Catch.Judgements
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The base health increase for the result achieved.
|
||||
/// Retrieves the numeric health increase of a <see cref="HitResult"/>.
|
||||
/// </summary>
|
||||
public float HealthIncrease => HealthIncreaseFor(Result);
|
||||
|
||||
/// <summary>
|
||||
/// Whether fruit on the platter should explode or drop.
|
||||
/// Note that this is only checked if the owning object is also <see cref="IHasComboInformation.LastInCombo" />
|
||||
/// </summary>
|
||||
public virtual bool ShouldExplode => IsHit;
|
||||
|
||||
/// <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>
|
||||
/// <param name="result">The <see cref="HitResult"/> to find the numeric health increase for.</param>
|
||||
/// <returns>The numeric health increase of <paramref name="result"/>.</returns>
|
||||
protected virtual float HealthIncreaseFor(HitResult result)
|
||||
{
|
||||
switch (result)
|
||||
@ -48,5 +37,18 @@ namespace osu.Game.Rulesets.Catch.Judgements
|
||||
return 10.2f;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves the numeric health increase of a <see cref="JudgementResult"/>.
|
||||
/// </summary>
|
||||
/// <param name="result">The <see cref="JudgementResult"/> to find the numeric health increase for.</param>
|
||||
/// <returns>The numeric health increase of <paramref name="result"/>.</returns>
|
||||
public float HealthIncreaseFor(JudgementResult result) => HealthIncreaseFor(result.Type);
|
||||
|
||||
/// <summary>
|
||||
/// Whether fruit on the platter should explode or drop.
|
||||
/// Note that this is only checked if the owning object is also <see cref="IHasComboInformation.LastInCombo" />
|
||||
/// </summary>
|
||||
public virtual bool ShouldExplodeFor(JudgementResult result) => result.IsHit;
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,9 @@
|
||||
// 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.Collections.Generic;
|
||||
using osu.Game.Rulesets.Catch.Judgements;
|
||||
using osu.Game.Rulesets.Judgements;
|
||||
|
||||
namespace osu.Game.Rulesets.Catch.Objects
|
||||
{
|
||||
@ -9,6 +11,6 @@ namespace osu.Game.Rulesets.Catch.Objects
|
||||
{
|
||||
public override FruitVisualRepresentation VisualRepresentation => FruitVisualRepresentation.Banana;
|
||||
|
||||
public override CatchJudgement Judgement { get; } = new CatchBananaJudgement();
|
||||
protected override IEnumerable<Judgement> CreateJudgements() => new[] { new CatchBananaJudgement() };
|
||||
}
|
||||
}
|
||||
|
@ -1,10 +1,8 @@
|
||||
// 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.Collections.Generic;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Beatmaps.ControlPoints;
|
||||
using osu.Game.Rulesets.Judgements;
|
||||
using osu.Game.Rulesets.Objects;
|
||||
using osu.Game.Rulesets.Objects.Types;
|
||||
|
||||
@ -56,12 +54,6 @@ namespace osu.Game.Rulesets.Catch.Objects
|
||||
}
|
||||
|
||||
protected override HitWindows CreateHitWindows() => null;
|
||||
|
||||
protected override IEnumerable<Judgement> CreateJudgements()
|
||||
{
|
||||
if (this is ICatchObjectWithJudgement judgeable)
|
||||
yield return judgeable.Judgement;
|
||||
}
|
||||
}
|
||||
|
||||
public enum FruitVisualRepresentation
|
||||
|
@ -2,6 +2,7 @@
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using System;
|
||||
using System.Linq;
|
||||
using OpenTK;
|
||||
using OpenTK.Graphics;
|
||||
using osu.Framework.Graphics;
|
||||
@ -56,10 +57,8 @@ namespace osu.Game.Rulesets.Catch.Objects.Drawable
|
||||
{
|
||||
if (CheckPosition == null) return;
|
||||
|
||||
if (timeOffset >= 0 && HitObject is ICatchObjectWithJudgement judgeable)
|
||||
{
|
||||
ApplyJudgement(judgeable.Judgement, j => j.Result = CheckPosition.Invoke(HitObject) ? HitResult.Perfect : HitResult.Miss);
|
||||
}
|
||||
if (timeOffset >= 0 && Results.Count > 0)
|
||||
ApplyResult(Results.Single(), r => r.Type = CheckPosition.Invoke(HitObject) ? HitResult.Perfect : HitResult.Miss);
|
||||
}
|
||||
|
||||
protected override void SkinChanged(ISkinSource skin, bool allowFallback)
|
||||
|
@ -1,12 +1,14 @@
|
||||
// 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.Collections.Generic;
|
||||
using osu.Game.Rulesets.Catch.Judgements;
|
||||
using osu.Game.Rulesets.Judgements;
|
||||
|
||||
namespace osu.Game.Rulesets.Catch.Objects
|
||||
{
|
||||
public class Droplet : CatchHitObject, ICatchObjectWithJudgement
|
||||
public class Droplet : CatchHitObject
|
||||
{
|
||||
public virtual CatchJudgement Judgement { get; } = new CatchDropletJudgement();
|
||||
protected override IEnumerable<Judgement> CreateJudgements() => new[] { new CatchDropletJudgement() };
|
||||
}
|
||||
}
|
||||
|
@ -1,12 +1,14 @@
|
||||
// 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.Collections.Generic;
|
||||
using osu.Game.Rulesets.Catch.Judgements;
|
||||
using osu.Game.Rulesets.Judgements;
|
||||
|
||||
namespace osu.Game.Rulesets.Catch.Objects
|
||||
{
|
||||
public class Fruit : CatchHitObject, ICatchObjectWithJudgement
|
||||
public class Fruit : CatchHitObject
|
||||
{
|
||||
public virtual CatchJudgement Judgement { get; } = new CatchJudgement();
|
||||
protected override IEnumerable<Judgement> CreateJudgements() => new[] { new CatchJudgement() };
|
||||
}
|
||||
}
|
||||
|
@ -1,12 +0,0 @@
|
||||
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using osu.Game.Rulesets.Catch.Judgements;
|
||||
|
||||
namespace osu.Game.Rulesets.Catch.Objects
|
||||
{
|
||||
public interface ICatchObjectWithJudgement
|
||||
{
|
||||
CatchJudgement Judgement { get; }
|
||||
}
|
||||
}
|
@ -1,12 +1,14 @@
|
||||
// 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.Collections.Generic;
|
||||
using osu.Game.Rulesets.Catch.Judgements;
|
||||
using osu.Game.Rulesets.Judgements;
|
||||
|
||||
namespace osu.Game.Rulesets.Catch.Objects
|
||||
{
|
||||
public class TinyDroplet : Droplet
|
||||
{
|
||||
public override CatchJudgement Judgement { get; } = new CatchTinyDropletJudgement();
|
||||
protected override IEnumerable<Judgement> CreateJudgements() => new[] { new CatchTinyDropletJudgement() };
|
||||
}
|
||||
}
|
||||
|
@ -2,7 +2,6 @@
|
||||
// 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;
|
||||
@ -21,55 +20,28 @@ namespace osu.Game.Rulesets.Catch.Scoring
|
||||
|
||||
private float hpDrainRate;
|
||||
|
||||
protected override void SimulateAutoplay(Beatmap<CatchHitObject> beatmap)
|
||||
protected override void ApplyBeatmap(Beatmap<CatchHitObject> beatmap)
|
||||
{
|
||||
hpDrainRate = beatmap.BeatmapInfo.BaseDifficulty.DrainRate;
|
||||
base.ApplyBeatmap(beatmap);
|
||||
|
||||
foreach (var obj in beatmap.HitObjects)
|
||||
{
|
||||
switch (obj)
|
||||
{
|
||||
case JuiceStream stream:
|
||||
foreach (var nestedObject in stream.NestedHitObjects)
|
||||
switch (nestedObject)
|
||||
{
|
||||
case TinyDroplet _:
|
||||
AddJudgement(new CatchTinyDropletJudgement { Result = HitResult.Perfect });
|
||||
break;
|
||||
case Droplet _:
|
||||
AddJudgement(new CatchDropletJudgement { Result = HitResult.Perfect });
|
||||
break;
|
||||
case Fruit _:
|
||||
AddJudgement(new CatchJudgement { Result = HitResult.Perfect });
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case BananaShower shower:
|
||||
foreach (var _ in shower.NestedHitObjects.Cast<CatchHitObject>())
|
||||
AddJudgement(new CatchBananaJudgement { Result = HitResult.Perfect });
|
||||
break;
|
||||
case Fruit _:
|
||||
AddJudgement(new CatchJudgement { Result = HitResult.Perfect });
|
||||
break;
|
||||
}
|
||||
}
|
||||
hpDrainRate = beatmap.BeatmapInfo.BaseDifficulty.DrainRate;
|
||||
}
|
||||
|
||||
private const double harshness = 0.01;
|
||||
|
||||
protected override void OnNewJudgement(Judgement judgement)
|
||||
protected override void OnNewJudgement(JudgementResult result)
|
||||
{
|
||||
base.OnNewJudgement(judgement);
|
||||
base.OnNewJudgement(result);
|
||||
|
||||
if (judgement.Result == HitResult.Miss)
|
||||
if (result.Type == HitResult.Miss)
|
||||
{
|
||||
if (!judgement.IsBonus)
|
||||
if (!result.Judgement.IsBonus)
|
||||
Health.Value -= hpDrainRate * (harshness * 2);
|
||||
return;
|
||||
}
|
||||
|
||||
if (judgement is CatchJudgement catchJudgement)
|
||||
Health.Value += Math.Max(catchJudgement.HealthIncrease - hpDrainRate, 0) * harshness;
|
||||
if (result.Judgement is CatchJudgement catchJudgement)
|
||||
Health.Value += Math.Max(catchJudgement.HealthIncreaseFor(result) - hpDrainRate, 0) * harshness;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -67,6 +67,7 @@ namespace osu.Game.Rulesets.Catch.UI
|
||||
fruit.CheckPosition = CheckIfWeCanCatch;
|
||||
}
|
||||
|
||||
private void onJudgement(DrawableHitObject judgedObject, Judgement judgement) => catcherArea.OnJudgement((DrawableCatchHitObject)judgedObject, judgement);
|
||||
private void onJudgement(DrawableHitObject judgedObject, JudgementResult result)
|
||||
=> catcherArea.OnJudgement((DrawableCatchHitObject)judgedObject, result);
|
||||
}
|
||||
}
|
||||
|
@ -48,7 +48,7 @@ namespace osu.Game.Rulesets.Catch.UI
|
||||
|
||||
private DrawableCatchHitObject lastPlateableFruit;
|
||||
|
||||
public void OnJudgement(DrawableCatchHitObject fruit, Judgement judgement)
|
||||
public void OnJudgement(DrawableCatchHitObject fruit, JudgementResult result)
|
||||
{
|
||||
void runAfterLoaded(Action action)
|
||||
{
|
||||
@ -63,7 +63,7 @@ namespace osu.Game.Rulesets.Catch.UI
|
||||
lastPlateableFruit.OnLoadComplete = _ => action();
|
||||
}
|
||||
|
||||
if (judgement.IsHit && fruit.CanBePlated)
|
||||
if (result.IsHit && fruit.CanBePlated)
|
||||
{
|
||||
var caughtFruit = (DrawableCatchHitObject)GetVisualRepresentation?.Invoke(fruit.HitObject);
|
||||
|
||||
@ -86,7 +86,7 @@ namespace osu.Game.Rulesets.Catch.UI
|
||||
|
||||
if (fruit.HitObject.LastInCombo)
|
||||
{
|
||||
if (((CatchJudgement)judgement).ShouldExplode)
|
||||
if (((CatchJudgement)result.Judgement).ShouldExplodeFor(result))
|
||||
runAfterLoaded(() => MovableCatcher.Explode());
|
||||
else
|
||||
MovableCatcher.Drop();
|
||||
|
Loading…
Reference in New Issue
Block a user