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

@ -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);
}
}