mirror of
https://github.com/ppy/osu
synced 2025-02-17 10:57:03 +00:00
Make taiko use the new nested hitobject structure
This commit is contained in:
parent
8d7453c251
commit
d49ef6a36b
@ -12,6 +12,7 @@ using osu.Game.Rulesets.Taiko.Objects.Drawables.Pieces;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Game.Rulesets.Judgements;
|
||||
using osu.Game.Rulesets.Objects;
|
||||
using osu.Game.Rulesets.Scoring;
|
||||
|
||||
namespace osu.Game.Rulesets.Taiko.Objects.Drawables
|
||||
@ -28,31 +29,18 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables
|
||||
/// </summary>
|
||||
private int rollingHits;
|
||||
|
||||
private readonly Container<DrawableDrumRollTick> tickContainer;
|
||||
|
||||
private Color4 colourIdle;
|
||||
private Color4 colourEngaged;
|
||||
|
||||
public DrawableDrumRoll(DrumRoll drumRoll)
|
||||
: base(drumRoll)
|
||||
{
|
||||
RelativeSizeAxes = Axes.Y;
|
||||
|
||||
Container<DrawableDrumRollTick> tickContainer;
|
||||
MainPiece.Add(tickContainer = new Container<DrawableDrumRollTick> { RelativeSizeAxes = Axes.Both });
|
||||
|
||||
foreach (var tick in drumRoll.NestedHitObjects.OfType<DrumRollTick>())
|
||||
{
|
||||
var newTick = new DrawableDrumRollTick(tick);
|
||||
newTick.OnNewResult += onNewTickResult;
|
||||
|
||||
AddNested(newTick);
|
||||
tickContainer.Add(newTick);
|
||||
}
|
||||
}
|
||||
|
||||
protected override TaikoPiece CreateMainPiece() => new ElongatedCirclePiece();
|
||||
|
||||
public override bool OnPressed(TaikoAction action) => false;
|
||||
|
||||
private Color4 colourIdle;
|
||||
private Color4 colourEngaged;
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuColour colours)
|
||||
{
|
||||
@ -60,8 +48,51 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables
|
||||
colourEngaged = colours.YellowDarker;
|
||||
}
|
||||
|
||||
private void onNewTickResult(DrawableHitObject obj, JudgementResult result)
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.LoadComplete();
|
||||
|
||||
OnNewResult += onNewResult;
|
||||
}
|
||||
|
||||
protected override void AddNested(DrawableHitObject h)
|
||||
{
|
||||
base.AddNested(h);
|
||||
|
||||
switch (h)
|
||||
{
|
||||
case DrawableDrumRollTick tick:
|
||||
tickContainer.Add(tick);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
protected override void ClearNested()
|
||||
{
|
||||
base.ClearNested();
|
||||
tickContainer.Clear();
|
||||
}
|
||||
|
||||
protected override DrawableHitObject CreateNested(HitObject hitObject)
|
||||
{
|
||||
switch (hitObject)
|
||||
{
|
||||
case DrumRollTick tick:
|
||||
return new DrawableDrumRollTick(tick);
|
||||
}
|
||||
|
||||
return base.CreateNested(hitObject);
|
||||
}
|
||||
|
||||
protected override TaikoPiece CreateMainPiece() => new ElongatedCirclePiece();
|
||||
|
||||
public override bool OnPressed(TaikoAction action) => false;
|
||||
|
||||
private void onNewResult(DrawableHitObject obj, JudgementResult result)
|
||||
{
|
||||
if (!(obj is DrawableDrumRollTick))
|
||||
return;
|
||||
|
||||
if (result.Type > HitResult.Miss)
|
||||
rollingHits++;
|
||||
else
|
||||
|
@ -2,7 +2,6 @@
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Extensions.Color4Extensions;
|
||||
@ -14,6 +13,7 @@ using osu.Game.Rulesets.Taiko.Objects.Drawables.Pieces;
|
||||
using osuTK;
|
||||
using osuTK.Graphics;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Game.Rulesets.Objects;
|
||||
using osu.Game.Rulesets.Scoring;
|
||||
|
||||
namespace osu.Game.Rulesets.Taiko.Objects.Drawables
|
||||
@ -30,8 +30,7 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables
|
||||
/// </summary>
|
||||
private const double ring_appear_offset = 100;
|
||||
|
||||
private readonly List<DrawableSwellTick> ticks = new List<DrawableSwellTick>();
|
||||
|
||||
private readonly Container<DrawableSwellTick> ticks;
|
||||
private readonly Container bodyContainer;
|
||||
private readonly CircularContainer targetRing;
|
||||
private readonly CircularContainer expandingRing;
|
||||
@ -108,16 +107,9 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables
|
||||
}
|
||||
});
|
||||
|
||||
AddInternal(ticks = new Container<DrawableSwellTick> { RelativeSizeAxes = Axes.Both });
|
||||
|
||||
MainPiece.Add(symbol = new SwellSymbolPiece());
|
||||
|
||||
foreach (var tick in HitObject.NestedHitObjects.OfType<SwellTick>())
|
||||
{
|
||||
var vis = new DrawableSwellTick(tick);
|
||||
|
||||
ticks.Add(vis);
|
||||
AddInternal(vis);
|
||||
AddNested(vis);
|
||||
}
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
@ -136,11 +128,49 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables
|
||||
Width *= Parent.RelativeChildSize.X;
|
||||
}
|
||||
|
||||
protected override void AddNested(DrawableHitObject h)
|
||||
{
|
||||
base.AddNested(h);
|
||||
|
||||
switch (h)
|
||||
{
|
||||
case DrawableSwellTick tick:
|
||||
ticks.Add(tick);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
protected override void ClearNested()
|
||||
{
|
||||
base.ClearNested();
|
||||
ticks.Clear();
|
||||
}
|
||||
|
||||
protected override DrawableHitObject CreateNested(HitObject hitObject)
|
||||
{
|
||||
switch (hitObject)
|
||||
{
|
||||
case SwellTick tick:
|
||||
return new DrawableSwellTick(tick);
|
||||
}
|
||||
|
||||
return base.CreateNested(hitObject);
|
||||
}
|
||||
|
||||
protected override void CheckForResult(bool userTriggered, double timeOffset)
|
||||
{
|
||||
if (userTriggered)
|
||||
{
|
||||
var nextTick = ticks.Find(j => !j.IsHit);
|
||||
DrawableSwellTick nextTick = null;
|
||||
|
||||
foreach (var t in ticks)
|
||||
{
|
||||
if (!t.IsHit)
|
||||
{
|
||||
nextTick = t;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
nextTick?.TriggerResult(HitResult.Great);
|
||||
|
||||
|
@ -11,6 +11,7 @@ using osu.Game.Audio;
|
||||
using System.Collections.Generic;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Primitives;
|
||||
using osu.Game.Rulesets.Objects;
|
||||
|
||||
namespace osu.Game.Rulesets.Taiko.Objects.Drawables
|
||||
{
|
||||
@ -109,11 +110,12 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables
|
||||
{
|
||||
public override Vector2 OriginPosition => new Vector2(DrawHeight / 2);
|
||||
|
||||
protected readonly Vector2 BaseSize;
|
||||
public new TaikoHitType HitObject;
|
||||
|
||||
protected readonly Vector2 BaseSize;
|
||||
protected readonly TaikoPiece MainPiece;
|
||||
|
||||
public new TaikoHitType HitObject;
|
||||
private readonly Container<DrawableStrongNestedHit> strongHitContainer;
|
||||
|
||||
protected DrawableTaikoHitObject(TaikoHitType hitObject)
|
||||
: base(hitObject)
|
||||
@ -129,17 +131,38 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables
|
||||
Content.Add(MainPiece = CreateMainPiece());
|
||||
MainPiece.KiaiMode = HitObject.Kiai;
|
||||
|
||||
var strongObject = HitObject.NestedHitObjects.OfType<StrongHitObject>().FirstOrDefault();
|
||||
AddInternal(strongHitContainer = new Container<DrawableStrongNestedHit>());
|
||||
}
|
||||
|
||||
if (strongObject != null)
|
||||
protected override void AddNested(DrawableHitObject h)
|
||||
{
|
||||
base.AddNested(h);
|
||||
|
||||
switch (h)
|
||||
{
|
||||
var strongHit = CreateStrongHit(strongObject);
|
||||
|
||||
AddNested(strongHit);
|
||||
AddInternal(strongHit);
|
||||
case DrawableStrongNestedHit strong:
|
||||
strongHitContainer.Add(strong);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
protected override void ClearNested()
|
||||
{
|
||||
base.ClearNested();
|
||||
strongHitContainer.Clear();
|
||||
}
|
||||
|
||||
protected override DrawableHitObject CreateNested(HitObject hitObject)
|
||||
{
|
||||
switch (hitObject)
|
||||
{
|
||||
case StrongHitObject strong:
|
||||
return CreateStrongHit(strong);
|
||||
}
|
||||
|
||||
return base.CreateNested(hitObject);
|
||||
}
|
||||
|
||||
// Normal and clap samples are handled by the drum
|
||||
protected override IEnumerable<HitSampleInfo> GetSamples() => HitObject.Samples.Where(s => s.Name != HitSampleInfo.HIT_NORMAL && s.Name != HitSampleInfo.HIT_CLAP);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user