Make Rulesets.Taiko use the new judgement result structure

This commit is contained in:
smoogipoo 2018-08-02 20:36:08 +09:00
parent 3619290c34
commit 9c2122c0ca
13 changed files with 96 additions and 106 deletions

View File

@ -11,6 +11,7 @@ using osu.Framework.MathUtils;
using osu.Framework.Timing;
using osu.Game.Beatmaps;
using osu.Game.Beatmaps.ControlPoints;
using osu.Game.Rulesets.Judgements;
using osu.Game.Rulesets.Objects;
using osu.Game.Rulesets.Objects.Drawables;
using osu.Game.Rulesets.Taiko.Judgements;
@ -143,18 +144,18 @@ namespace osu.Game.Rulesets.Taiko.Tests
var h = new DrawableTestHit(hit) { X = RNG.NextSingle(hitResult == HitResult.Good ? -0.1f : -0.05f, hitResult == HitResult.Good ? 0.1f : 0.05f) };
((TaikoPlayfield)rulesetContainer.Playfield).OnJudgement(h, new TaikoJudgement { Result = hitResult });
((TaikoPlayfield)rulesetContainer.Playfield).OnJudgement(h, new JudgementResult(new TaikoJudgement()) { Type = hitResult });
if (RNG.Next(10) == 0)
{
((TaikoPlayfield)rulesetContainer.Playfield).OnJudgement(h, new TaikoJudgement { Result = hitResult });
((TaikoPlayfield)rulesetContainer.Playfield).OnJudgement(h, new TaikoStrongHitJudgement());
((TaikoPlayfield)rulesetContainer.Playfield).OnJudgement(h, new JudgementResult(new TaikoJudgement()) { Type = hitResult });
((TaikoPlayfield)rulesetContainer.Playfield).OnJudgement(h, new JudgementResult(new TaikoStrongHitJudgement()) { Type = HitResult.Great });
}
}
private void addMissJudgement()
{
((TaikoPlayfield)rulesetContainer.Playfield).OnJudgement(new DrawableTestHit(new Hit()), new TaikoJudgement { Result = HitResult.Miss });
((TaikoPlayfield)rulesetContainer.Playfield).OnJudgement(new DrawableTestHit(new Hit()), new JudgementResult(new TaikoJudgement()) { Type = HitResult.Miss });
}
private void addBarLine(bool major, double delay = scroll_time)

View File

@ -7,7 +7,7 @@ namespace osu.Game.Rulesets.Taiko.Judgements
{
public class TaikoIntermediateSwellJudgement : TaikoJudgement
{
public override HitResult MaxResult => HitResult.Perfect;
public override HitResult MaxResult => HitResult.Great;
public override bool AffectsCombo => false;

View File

@ -13,6 +13,7 @@ using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Game.Rulesets.Judgements;
using osu.Game.Rulesets.Scoring;
using osu.Game.Rulesets.Taiko.Judgements;
namespace osu.Game.Rulesets.Taiko.Objects.Drawables
{
@ -23,6 +24,9 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables
/// </summary>
private const int rolling_hits_for_engaged_colour = 5;
private readonly JudgementResult result;
private readonly JudgementResult strongResult;
/// <summary>
/// Rolling number of tick hits. This increases for hits and decreases for misses.
/// </summary>
@ -44,6 +48,9 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables
AddNested(newTick);
tickContainer.Add(newTick);
}
result = Results.Single(r => !(r.Judgement is TaikoStrongHitJudgement));
strongResult = Results.SingleOrDefault(r => r.Judgement is TaikoStrongHitJudgement);
}
protected override TaikoPiece CreateMainPiece() => new ElongatedCirclePiece();
@ -60,9 +67,9 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables
colourEngaged = colours.YellowDarker;
}
private void onTickJudgement(DrawableHitObject obj, Judgement judgement)
private void onTickJudgement(DrawableHitObject obj, JudgementResult result)
{
if (judgement.Result > HitResult.Miss)
if (result.Type > HitResult.Miss)
rollingHits++;
else
rollingHits--;
@ -84,15 +91,15 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables
int countHit = NestedHitObjects.Count(o => o.IsHit);
if (countHit >= HitObject.RequiredGoodHits)
{
ApplyJudgement(HitObject.Judgement, j => j.Result = countHit >= HitObject.RequiredGreatHits ? HitResult.Great : HitResult.Good);
ApplyResult(result, r => r.Type = countHit >= HitObject.RequiredGreatHits ? HitResult.Great : HitResult.Good);
if (HitObject.IsStrong)
ApplyJudgement(HitObject.StrongJudgement, j => j.Result = HitResult.Great);
ApplyResult(strongResult, r => r.Type = HitResult.Great);
}
else
{
ApplyJudgement(HitObject.Judgement, j => j.Result = HitResult.Miss);
ApplyResult(result, r => r.Type = HitResult.Miss);
if (HitObject.IsStrong)
ApplyJudgement(HitObject.StrongJudgement, j => j.Result = HitResult.Miss);
ApplyResult(strongResult, r => r.Type = HitResult.Miss);
}
}

View File

@ -2,19 +2,28 @@
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System;
using System.Linq;
using osu.Framework.Graphics;
using osu.Game.Rulesets.Judgements;
using osu.Game.Rulesets.Objects.Drawables;
using osu.Game.Rulesets.Scoring;
using osu.Game.Rulesets.Taiko.Judgements;
using osu.Game.Rulesets.Taiko.Objects.Drawables.Pieces;
namespace osu.Game.Rulesets.Taiko.Objects.Drawables
{
public class DrawableDrumRollTick : DrawableTaikoHitObject<DrumRollTick>
{
private readonly JudgementResult result;
private readonly JudgementResult strongResult;
public DrawableDrumRollTick(DrumRollTick tick)
: base(tick)
{
FillMode = FillMode.Fit;
result = Results.Single(r => !(r.Judgement is TaikoStrongHitJudgement));
strongResult = Results.SingleOrDefault(r => r.Judgement is TaikoStrongHitJudgement);
}
public override bool DisplayJudgement => false;
@ -30,9 +39,9 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables
{
if (timeOffset > HitObject.HitWindow)
{
ApplyJudgement(HitObject.Judgement, j => j.Result = HitResult.Miss);
ApplyResult(result, r => r.Type = HitResult.Miss);
if (HitObject.IsStrong)
ApplyJudgement(HitObject.StrongJudgement, j => j.Result = HitResult.Miss);
ApplyResult(strongResult, r => r.Type = HitResult.Miss);
}
return;
@ -41,9 +50,9 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables
if (Math.Abs(timeOffset) > HitObject.HitWindow)
return;
ApplyJudgement(HitObject.Judgement, j => j.Result = HitResult.Great);
ApplyResult(result, r => r.Type = HitResult.Great);
if (HitObject.IsStrong)
ApplyJudgement(HitObject.StrongJudgement, j => j.Result = HitResult.Great);
ApplyResult(strongResult, r => r.Type = HitResult.Great);
}
protected override void UpdateState(ArmedState state)

View File

@ -3,8 +3,10 @@
using System.Linq;
using osu.Framework.Graphics;
using osu.Game.Rulesets.Judgements;
using osu.Game.Rulesets.Objects.Drawables;
using osu.Game.Rulesets.Scoring;
using osu.Game.Rulesets.Taiko.Judgements;
using osu.Game.Rulesets.Taiko.Objects.Drawables.Pieces;
namespace osu.Game.Rulesets.Taiko.Objects.Drawables
@ -16,6 +18,8 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables
/// </summary>
protected abstract TaikoAction[] HitActions { get; }
protected readonly JudgementResult Result;
/// <summary>
/// Whether the last key pressed is a valid hit key.
/// </summary>
@ -25,6 +29,8 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables
: base(hit)
{
FillMode = FillMode.Fit;
Result = Results.Single(r => !(r.Judgement is TaikoStrongHitJudgement));
}
protected override void CheckForJudgements(bool userTriggered, double timeOffset)
@ -32,7 +38,7 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables
if (!userTriggered)
{
if (!HitObject.HitWindows.CanBeHit(timeOffset))
ApplyJudgement(HitObject.Judgement, j => j.Result = HitResult.Miss);
ApplyResult(Result, r => r.Type = HitResult.Miss);
return;
}
@ -40,10 +46,10 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables
if (result == HitResult.None)
return;
if (!validKeyPressed || result == HitResult.Miss)
ApplyJudgement(HitObject.Judgement, j => j.Result = HitResult.Miss);
if (!validKeyPressed)
ApplyResult(Result, r => r.Type = HitResult.Miss);
else
ApplyJudgement(HitObject.Judgement, j => j.Result = result);
ApplyResult(Result, r => r.Type = result);
}
public override bool OnPressed(TaikoAction action)

View File

@ -3,8 +3,10 @@
using System;
using System.Linq;
using osu.Game.Rulesets.Judgements;
using osu.Game.Rulesets.Objects.Drawables;
using osu.Game.Rulesets.Scoring;
using osu.Game.Rulesets.Taiko.Judgements;
namespace osu.Game.Rulesets.Taiko.Objects.Drawables
{
@ -16,6 +18,8 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables
/// </summary>
private const double second_hit_window = 30;
private readonly JudgementResult strongResult;
private double firstHitTime;
private bool firstKeyHeld;
private TaikoAction firstHitAction;
@ -23,31 +27,32 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables
protected DrawableHitStrong(Hit hit)
: base(hit)
{
strongResult = Results.SingleOrDefault(r => r.Judgement is TaikoStrongHitJudgement);
}
protected override void CheckForJudgements(bool userTriggered, double timeOffset)
{
if (!HitObject.Judgement.HasResult)
if (!Result.HasResult)
{
base.CheckForJudgements(userTriggered, timeOffset);
return;
}
if (!HitObject.Judgement.IsHit)
if (!Result.IsHit)
{
ApplyJudgement(HitObject.StrongJudgement, j => j.Result = HitResult.Miss);
ApplyResult(strongResult, r => r.Type = HitResult.Miss);
return;
}
if (!userTriggered)
{
if (timeOffset > second_hit_window)
ApplyJudgement(HitObject.StrongJudgement, j => j.Result = HitResult.Miss);
ApplyResult(strongResult, r => r.Type = HitResult.Miss);
return;
}
if (Math.Abs(firstHitTime - Time.Current) < second_hit_window)
ApplyJudgement(HitObject.StrongJudgement, j => j.Result = HitResult.Great);
ApplyResult(strongResult, r => r.Type = HitResult.Great);
}
protected override void UpdateState(ArmedState state)
@ -76,7 +81,7 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables
return false;
// Check if we've handled the first key
if (!HitObject.Judgement.HasResult)
if (!Result.HasResult)
{
// First key hasn't been handled yet, attempt to handle it
bool handled = base.OnPressed(action);

View File

@ -2,6 +2,7 @@
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System;
using System.Collections.Generic;
using System.Linq;
using osu.Framework.Allocation;
using osu.Framework.Extensions.Color4Extensions;
@ -13,7 +14,9 @@ using osu.Game.Rulesets.Taiko.Objects.Drawables.Pieces;
using OpenTK;
using OpenTK.Graphics;
using osu.Framework.Graphics.Shapes;
using osu.Game.Rulesets.Judgements;
using osu.Game.Rulesets.Scoring;
using osu.Game.Rulesets.Taiko.Judgements;
namespace osu.Game.Rulesets.Taiko.Objects.Drawables
{
@ -29,6 +32,9 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables
private const float target_ring_scale = 5f;
private const float inner_ring_alpha = 0.65f;
private readonly JudgementResult result;
private readonly List<JudgementResult> intermediateResults;
private readonly Container bodyContainer;
private readonly CircularContainer targetRing;
private readonly CircularContainer expandingRing;
@ -106,6 +112,9 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables
});
MainPiece.Add(symbol = new SwellSymbolPiece());
result = Results.Single(r => !(r.Judgement is TaikoIntermediateSwellJudgement));
intermediateResults = Results.Where(r => r.Judgement is TaikoIntermediateSwellJudgement).ToList();
}
[BackgroundDependencyLoader]
@ -128,12 +137,12 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables
{
if (userTriggered)
{
var nextIntermediate = HitObject.IntermediateJudgements.FirstOrDefault(j => !j.HasResult);
var nextIntermediate = intermediateResults.FirstOrDefault(j => !j.HasResult);
if (nextIntermediate != null)
ApplyJudgement(nextIntermediate, j => j.Result = HitResult.Great);
ApplyResult(nextIntermediate, r => r.Type = HitResult.Great);
var numHits = HitObject.IntermediateJudgements.Count(j => j.HasResult);
var numHits = intermediateResults.Count(r => r.HasResult);
var completion = (float)numHits / HitObject.RequiredHits;
@ -147,7 +156,7 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables
expandingRing.ScaleTo(1f + Math.Min(target_ring_scale - 1f, (target_ring_scale - 1f) * completion * 1.3f), 260, Easing.OutQuint);
if (numHits == HitObject.RequiredHits)
ApplyJudgement(HitObject.Judgement, j => j.Result = HitResult.Great);
ApplyResult(result, r => r.Type = HitResult.Great);
}
else
{
@ -156,7 +165,7 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables
int numHits = 0;
foreach (var intermediate in HitObject.IntermediateJudgements)
foreach (var intermediate in intermediateResults)
{
if (intermediate.HasResult)
{
@ -164,10 +173,12 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables
continue;
}
ApplyJudgement(intermediate, j => j.Result = HitResult.Miss);
ApplyResult(intermediate, r => r.Type = HitResult.Miss);
}
ApplyJudgement(HitObject.Judgement, j => j.Result = numHits > HitObject.RequiredHits / 2 ? HitResult.Good : HitResult.Miss);
var hitResult = numHits > HitObject.RequiredHits / 2 ? HitResult.Good : HitResult.Miss;
ApplyResult(result, r => r.Type = hitResult);
}
}

View File

@ -85,15 +85,12 @@ namespace osu.Game.Rulesets.Taiko.Objects
}
}
public TaikoJudgement Judgement { get; private set; }
public TaikoStrongHitJudgement StrongJudgement { get; private set; }
protected override IEnumerable<Judgement> CreateJudgements()
{
yield return Judgement = new TaikoJudgement();
yield return new TaikoJudgement();
if (IsStrong)
yield return StrongJudgement = new TaikoStrongHitJudgement();
yield return new TaikoStrongHitJudgement();
}
}
}

View File

@ -9,15 +9,12 @@ namespace osu.Game.Rulesets.Taiko.Objects
{
public class Hit : TaikoHitObject
{
public TaikoJudgement Judgement { get; private set; }
public TaikoStrongHitJudgement StrongJudgement { get; private set; }
protected override IEnumerable<Judgement> CreateJudgements()
{
yield return Judgement = new TaikoJudgement();
yield return new TaikoJudgement();
if (IsStrong)
yield return StrongJudgement = new TaikoStrongHitJudgement();
yield return new TaikoStrongHitJudgement();
}
}
}

View File

@ -19,22 +19,12 @@ namespace osu.Game.Rulesets.Taiko.Objects
/// </summary>
public int RequiredHits = 10;
public TaikoJudgement Judgement { get; private set; }
private readonly List<TaikoIntermediateSwellJudgement> intermediateJudgements = new List<TaikoIntermediateSwellJudgement>();
public IReadOnlyList<TaikoIntermediateSwellJudgement> IntermediateJudgements => intermediateJudgements;
protected override IEnumerable<Judgement> CreateJudgements()
{
yield return Judgement = new TaikoJudgement();
yield return new TaikoJudgement();
for (int i = 0; i < RequiredHits; i++)
{
var intermediate = new TaikoIntermediateSwellJudgement();
intermediateJudgements.Add(intermediate);
yield return intermediate;
}
yield return new TaikoIntermediateSwellJudgement();
}
}
}

View File

@ -1,7 +1,6 @@
// 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.Linq;
using osu.Game.Beatmaps;
using osu.Game.Rulesets.Judgements;
using osu.Game.Rulesets.Scoring;
@ -60,63 +59,31 @@ namespace osu.Game.Rulesets.Taiko.Scoring
private double hpIncreaseGood;
private double hpIncreaseMiss;
public TaikoScoreProcessor()
{
}
public TaikoScoreProcessor(RulesetContainer<TaikoHitObject> rulesetContainer)
: base(rulesetContainer)
{
}
protected override void SimulateAutoplay(Beatmap<TaikoHitObject> beatmap)
protected override void ApplyBeatmap(Beatmap<TaikoHitObject> beatmap)
{
base.ApplyBeatmap(beatmap);
double hpMultiplierNormal = 1 / (hp_hit_great * beatmap.HitObjects.FindAll(o => o is Hit).Count * BeatmapDifficulty.DifficultyRange(beatmap.BeatmapInfo.BaseDifficulty.DrainRate, 0.5, 0.75, 0.98));
hpIncreaseTick = hp_hit_tick;
hpIncreaseGreat = hpMultiplierNormal * hp_hit_great;
hpIncreaseGood = hpMultiplierNormal * hp_hit_good;
hpIncreaseMiss = BeatmapDifficulty.DifficultyRange(beatmap.BeatmapInfo.BaseDifficulty.DrainRate, hp_miss_min, hp_miss_mid, hp_miss_max);
foreach (var obj in beatmap.HitObjects)
{
switch (obj)
{
case Hit _:
AddJudgement(new TaikoJudgement { Result = HitResult.Great });
if (obj.IsStrong)
AddJudgement(new TaikoStrongHitJudgement());
break;
case DrumRoll drumRoll:
var count = drumRoll.NestedHitObjects.OfType<DrumRollTick>().Count();
for (int i = 0; i < count; i++)
{
AddJudgement(new TaikoDrumRollTickJudgement { Result = HitResult.Great });
if (obj.IsStrong)
AddJudgement(new TaikoStrongHitJudgement());
}
AddJudgement(new TaikoJudgement { Result = HitResult.Great });
if (obj.IsStrong)
AddJudgement(new TaikoStrongHitJudgement());
break;
case Swell _:
AddJudgement(new TaikoJudgement { Result = HitResult.Great });
break;
}
}
}
protected override void OnNewJudgement(Judgement judgement)
protected override void OnNewJudgement(JudgementResult result)
{
base.OnNewJudgement(judgement);
base.OnNewJudgement(result);
bool isTick = judgement is TaikoDrumRollTickJudgement;
bool isTick = result.Judgement is TaikoDrumRollTickJudgement;
// Apply HP changes
switch (judgement.Result)
switch (result.Type)
{
case HitResult.Miss:
// Missing ticks shouldn't drop HP

View File

@ -19,16 +19,16 @@ namespace osu.Game.Rulesets.Taiko.UI
/// Creates a new judgement text.
/// </summary>
/// <param name="judgedObject">The object which is being judged.</param>
/// <param name="judgement">The judgement to visualise.</param>
public DrawableTaikoJudgement(Judgement judgement, DrawableHitObject judgedObject)
: base(judgement, judgedObject)
/// <param name="result">The judgement to visualise.</param>
public DrawableTaikoJudgement(JudgementResult result, DrawableHitObject judgedObject)
: base(result, judgedObject)
{
}
[BackgroundDependencyLoader]
private void load(OsuColour colours)
{
switch (Judgement.Result)
switch (Result.Type)
{
case HitResult.Good:
Colour = colours.GreenLight;
@ -41,7 +41,7 @@ namespace osu.Game.Rulesets.Taiko.UI
protected override void LoadComplete()
{
if (Judgement.IsHit)
if (Result.IsHit)
this.MoveToY(-100, 500);
base.LoadComplete();

View File

@ -224,28 +224,28 @@ namespace osu.Game.Rulesets.Taiko.UI
}
}
internal void OnJudgement(DrawableHitObject judgedObject, Judgement judgement)
internal void OnJudgement(DrawableHitObject judgedObject, JudgementResult result)
{
if (!DisplayJudgements)
return;
if (judgedObject.DisplayJudgement && judgementContainer.FirstOrDefault(j => j.JudgedObject == judgedObject) == null)
{
judgementContainer.Add(new DrawableTaikoJudgement(judgement, judgedObject)
judgementContainer.Add(new DrawableTaikoJudgement(result, judgedObject)
{
Anchor = judgement.IsHit ? Anchor.TopLeft : Anchor.CentreLeft,
Origin = judgement.IsHit ? Anchor.BottomCentre : Anchor.Centre,
Anchor = result.IsHit ? Anchor.TopLeft : Anchor.CentreLeft,
Origin = result.IsHit ? Anchor.BottomCentre : Anchor.Centre,
RelativePositionAxes = Axes.X,
X = judgement.IsHit ? judgedObject.Position.X : 0,
X = result.IsHit ? judgedObject.Position.X : 0,
});
}
if (!judgement.IsHit)
if (!result.IsHit)
return;
bool isRim = judgedObject.HitObject is RimHit;
if (judgement is TaikoStrongHitJudgement)
if (result.Judgement is TaikoStrongHitJudgement)
hitExplosionContainer.Children.FirstOrDefault(e => e.JudgedObject == judgedObject)?.VisualiseSecondHit();
else
{