Migrate swells to use nested hitobjects for ticks

This commit is contained in:
smoogipoo
2018-08-03 16:35:29 +09:00
parent e8a140930e
commit 19c541dbf5
5 changed files with 62 additions and 19 deletions

View File

@ -14,9 +14,7 @@ using osu.Game.Rulesets.Taiko.Objects.Drawables.Pieces;
using OpenTK; using OpenTK;
using OpenTK.Graphics; using OpenTK.Graphics;
using osu.Framework.Graphics.Shapes; using osu.Framework.Graphics.Shapes;
using osu.Game.Rulesets.Judgements;
using osu.Game.Rulesets.Scoring; using osu.Game.Rulesets.Scoring;
using osu.Game.Rulesets.Taiko.Judgements;
namespace osu.Game.Rulesets.Taiko.Objects.Drawables namespace osu.Game.Rulesets.Taiko.Objects.Drawables
{ {
@ -32,8 +30,7 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables
private const float target_ring_scale = 5f; private const float target_ring_scale = 5f;
private const float inner_ring_alpha = 0.65f; private const float inner_ring_alpha = 0.65f;
private readonly JudgementResult result; private readonly List<DrawableSwellTick> ticks = new List<DrawableSwellTick>();
private readonly List<JudgementResult> intermediateResults;
private readonly Container bodyContainer; private readonly Container bodyContainer;
private readonly CircularContainer targetRing; private readonly CircularContainer targetRing;
@ -113,8 +110,14 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables
MainPiece.Add(symbol = new SwellSymbolPiece()); MainPiece.Add(symbol = new SwellSymbolPiece());
result = Results.Single(r => !(r.Judgement is TaikoIntermediateSwellJudgement)); foreach (var tick in HitObject.NestedHitObjects.OfType<SwellTick>())
intermediateResults = Results.Where(r => r.Judgement is TaikoIntermediateSwellJudgement).ToList(); {
var vis = new DrawableSwellTick(tick);
ticks.Add(vis);
AddInternal(vis);
AddNested(vis);
}
} }
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
@ -137,12 +140,11 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables
{ {
if (userTriggered) if (userTriggered)
{ {
var nextIntermediate = intermediateResults.FirstOrDefault(j => !j.HasResult); var nextTick = ticks.FirstOrDefault(j => !j.IsHit);
if (nextIntermediate != null) nextTick?.TriggerResult(HitResult.Great);
ApplyResult(nextIntermediate, r => r.Type = HitResult.Great);
var numHits = intermediateResults.Count(r => r.HasResult); var numHits = ticks.Count(r => r.IsHit);
var completion = (float)numHits / HitObject.RequiredHits; var completion = (float)numHits / HitObject.RequiredHits;
@ -156,7 +158,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); expandingRing.ScaleTo(1f + Math.Min(target_ring_scale - 1f, (target_ring_scale - 1f) * completion * 1.3f), 260, Easing.OutQuint);
if (numHits == HitObject.RequiredHits) if (numHits == HitObject.RequiredHits)
ApplyResult(result, r => r.Type = HitResult.Great); ApplyResult(r => r.Type = HitResult.Great);
} }
else else
{ {
@ -165,20 +167,20 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables
int numHits = 0; int numHits = 0;
foreach (var intermediate in intermediateResults) foreach (var tick in ticks)
{ {
if (intermediate.HasResult) if (tick.IsHit)
{ {
numHits++; numHits++;
continue; continue;
} }
ApplyResult(intermediate, r => r.Type = HitResult.Miss); tick.TriggerResult(HitResult.Miss);
} }
var hitResult = numHits > HitObject.RequiredHits / 2 ? HitResult.Good : HitResult.Miss; var hitResult = numHits > HitObject.RequiredHits / 2 ? HitResult.Good : HitResult.Miss;
ApplyResult(result, r => r.Type = hitResult); ApplyResult(r => r.Type = hitResult);
} }
} }

View File

@ -0,0 +1,28 @@
// 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.Objects.Drawables;
using osu.Game.Rulesets.Scoring;
namespace osu.Game.Rulesets.Taiko.Objects.Drawables
{
public class DrawableSwellTick : DrawableTaikoHitObject
{
public DrawableSwellTick(TaikoHitObject hitObject)
: base(hitObject)
{
}
public void TriggerResult(HitResult type) => ApplyResult(r => r.Type = type);
protected override void CheckForJudgements(bool userTriggered, double timeOffset)
{
}
protected override void UpdateState(ArmedState state)
{
}
public override bool OnPressed(TaikoAction action) => false;
}
}

View File

@ -15,5 +15,13 @@ namespace osu.Game.Rulesets.Taiko.Objects
/// The number of hits required to complete the swell successfully. /// The number of hits required to complete the swell successfully.
/// </summary> /// </summary>
public int RequiredHits = 10; public int RequiredHits = 10;
protected override void CreateNestedHitObjects()
{
base.CreateNestedHitObjects();
for (int i = 0; i < RequiredHits; i++)
AddNested(new SwellTick());
}
} }
} }

View File

@ -0,0 +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
namespace osu.Game.Rulesets.Taiko.Objects
{
public class SwellTick : TaikoHitObject
{
}
}

View File

@ -100,12 +100,8 @@ namespace osu.Game.Rulesets.Taiko.UI
{ {
switch (h) switch (h)
{ {
case CentreHit centreHit when h.IsStrong:
return new DrawableCentreHitStrong(centreHit);
case CentreHit centreHit: case CentreHit centreHit:
return new DrawableCentreHit(centreHit); return new DrawableCentreHit(centreHit);
case RimHit rimHit when h.IsStrong:
return new DrawableRimHitStrong(rimHit);
case RimHit rimHit: case RimHit rimHit:
return new DrawableRimHit(rimHit); return new DrawableRimHit(rimHit);
case DrumRoll drumRoll: case DrumRoll drumRoll: