mirror of https://github.com/ppy/osu
Migrate swells to use nested hitobjects for ticks
This commit is contained in:
parent
e8a140930e
commit
19c541dbf5
|
@ -14,9 +14,7 @@
|
|||
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
|
||||
{
|
||||
|
@ -32,8 +30,7 @@ public class DrawableSwell : DrawableTaikoHitObject<Swell>
|
|||
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 List<DrawableSwellTick> ticks = new List<DrawableSwellTick>();
|
||||
|
||||
private readonly Container bodyContainer;
|
||||
private readonly CircularContainer targetRing;
|
||||
|
@ -113,8 +110,14 @@ public DrawableSwell(Swell swell)
|
|||
|
||||
MainPiece.Add(symbol = new SwellSymbolPiece());
|
||||
|
||||
result = Results.Single(r => !(r.Judgement is TaikoIntermediateSwellJudgement));
|
||||
intermediateResults = Results.Where(r => r.Judgement is TaikoIntermediateSwellJudgement).ToList();
|
||||
foreach (var tick in HitObject.NestedHitObjects.OfType<SwellTick>())
|
||||
{
|
||||
var vis = new DrawableSwellTick(tick);
|
||||
|
||||
ticks.Add(vis);
|
||||
AddInternal(vis);
|
||||
AddNested(vis);
|
||||
}
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
|
@ -137,12 +140,11 @@ protected override void CheckForJudgements(bool userTriggered, double timeOffset
|
|||
{
|
||||
if (userTriggered)
|
||||
{
|
||||
var nextIntermediate = intermediateResults.FirstOrDefault(j => !j.HasResult);
|
||||
var nextTick = ticks.FirstOrDefault(j => !j.IsHit);
|
||||
|
||||
if (nextIntermediate != null)
|
||||
ApplyResult(nextIntermediate, r => r.Type = HitResult.Great);
|
||||
nextTick?.TriggerResult(HitResult.Great);
|
||||
|
||||
var numHits = intermediateResults.Count(r => r.HasResult);
|
||||
var numHits = ticks.Count(r => r.IsHit);
|
||||
|
||||
var completion = (float)numHits / HitObject.RequiredHits;
|
||||
|
||||
|
@ -156,7 +158,7 @@ protected override void CheckForJudgements(bool userTriggered, double timeOffset
|
|||
expandingRing.ScaleTo(1f + Math.Min(target_ring_scale - 1f, (target_ring_scale - 1f) * completion * 1.3f), 260, Easing.OutQuint);
|
||||
|
||||
if (numHits == HitObject.RequiredHits)
|
||||
ApplyResult(result, r => r.Type = HitResult.Great);
|
||||
ApplyResult(r => r.Type = HitResult.Great);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -165,20 +167,20 @@ protected override void CheckForJudgements(bool userTriggered, double timeOffset
|
|||
|
||||
int numHits = 0;
|
||||
|
||||
foreach (var intermediate in intermediateResults)
|
||||
foreach (var tick in ticks)
|
||||
{
|
||||
if (intermediate.HasResult)
|
||||
if (tick.IsHit)
|
||||
{
|
||||
numHits++;
|
||||
continue;
|
||||
}
|
||||
|
||||
ApplyResult(intermediate, r => r.Type = HitResult.Miss);
|
||||
tick.TriggerResult(HitResult.Miss);
|
||||
}
|
||||
|
||||
var hitResult = numHits > HitObject.RequiredHits / 2 ? HitResult.Good : HitResult.Miss;
|
||||
|
||||
ApplyResult(result, r => r.Type = hitResult);
|
||||
ApplyResult(r => r.Type = hitResult);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -15,5 +15,13 @@ public class Swell : TaikoHitObject, IHasEndTime
|
|||
/// The number of hits required to complete the swell successfully.
|
||||
/// </summary>
|
||||
public int RequiredHits = 10;
|
||||
|
||||
protected override void CreateNestedHitObjects()
|
||||
{
|
||||
base.CreateNestedHitObjects();
|
||||
|
||||
for (int i = 0; i < RequiredHits; i++)
|
||||
AddNested(new SwellTick());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
{
|
||||
}
|
||||
}
|
|
@ -100,12 +100,8 @@ protected override DrawableHitObject<TaikoHitObject> GetVisualRepresentation(Tai
|
|||
{
|
||||
switch (h)
|
||||
{
|
||||
case CentreHit centreHit when h.IsStrong:
|
||||
return new DrawableCentreHitStrong(centreHit);
|
||||
case CentreHit centreHit:
|
||||
return new DrawableCentreHit(centreHit);
|
||||
case RimHit rimHit when h.IsStrong:
|
||||
return new DrawableRimHitStrong(rimHit);
|
||||
case RimHit rimHit:
|
||||
return new DrawableRimHit(rimHit);
|
||||
case DrumRoll drumRoll:
|
||||
|
|
Loading…
Reference in New Issue