1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-16 03:42:58 +08:00

Reduce complexity of instantiating circle pieces in hits.

This commit is contained in:
smoogipooo 2017-04-03 14:39:56 +09:00
parent ef992b03bf
commit 6e612bbefc
5 changed files with 35 additions and 42 deletions

View File

@ -12,24 +12,20 @@ namespace osu.Game.Modes.Taiko.Objects.Drawable
{ {
protected override Key[] HitKeys { get; } = { Key.F, Key.J }; protected override Key[] HitKeys { get; } = { Key.F, Key.J };
private readonly CirclePiece circlePiece;
public DrawableCentreHit(Hit hit) public DrawableCentreHit(Hit hit)
: base(hit) : base(hit)
{ {
Add(circlePiece = new CirclePiece
{
Children = new[]
{
new CentreHitSymbolPiece()
}
});
} }
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(OsuColour colours) private void load(OsuColour colours)
{ {
circlePiece.AccentColour = colours.PinkDarker; Circle.AccentColour = colours.PinkDarker;
} }
protected override CirclePiece CreateCirclePiece() => new CirclePiece
{
Children = new[] { new CentreHitSymbolPiece() }
};
} }
} }

View File

@ -6,6 +6,7 @@ using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Game.Modes.Objects.Drawables; using osu.Game.Modes.Objects.Drawables;
using osu.Game.Modes.Taiko.Judgements; using osu.Game.Modes.Taiko.Judgements;
using osu.Game.Modes.Taiko.Objects.Drawable.Pieces;
using System; using System;
using System.Linq; using System.Linq;
@ -20,15 +21,17 @@ namespace osu.Game.Modes.Taiko.Objects.Drawable
protected override Container<Framework.Graphics.Drawable> Content => bodyContainer; protected override Container<Framework.Graphics.Drawable> Content => bodyContainer;
protected readonly CirclePiece Circle;
private readonly Hit hit; private readonly Hit hit;
private readonly Container bodyContainer;
/// <summary> /// <summary>
/// Whether the last key pressed is a valid hit key. /// Whether the last key pressed is a valid hit key.
/// </summary> /// </summary>
private bool validKeyPressed; private bool validKeyPressed;
private readonly Container bodyContainer;
protected DrawableHit(Hit hit) protected DrawableHit(Hit hit)
: base(hit) : base(hit)
{ {
@ -38,6 +41,10 @@ namespace osu.Game.Modes.Taiko.Objects.Drawable
{ {
Anchor = Anchor.Centre, Anchor = Anchor.Centre,
Origin = Anchor.Centre, Origin = Anchor.Centre,
Children = new[]
{
Circle = CreateCirclePiece()
}
}); });
} }
@ -100,5 +107,7 @@ namespace osu.Game.Modes.Taiko.Objects.Drawable
Expire(); Expire();
} }
protected abstract CirclePiece CreateCirclePiece();
} }
} }

View File

@ -12,24 +12,20 @@ namespace osu.Game.Modes.Taiko.Objects.Drawable
{ {
protected override Key[] HitKeys { get; } = { Key.D, Key.K }; protected override Key[] HitKeys { get; } = { Key.D, Key.K };
private readonly CirclePiece circlePiece;
public DrawableRimHit(Hit hit) public DrawableRimHit(Hit hit)
: base(hit) : base(hit)
{ {
Add(circlePiece = new CirclePiece
{
Children = new[]
{
new RimHitSymbolPiece()
}
});
} }
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(OsuColour colours) private void load(OsuColour colours)
{ {
circlePiece.AccentColour = colours.BlueDarker; Circle.AccentColour = colours.BlueDarker;
} }
protected override CirclePiece CreateCirclePiece() => new CirclePiece
{
Children = new[] { new RimHitSymbolPiece() }
};
} }
} }

View File

@ -12,24 +12,20 @@ namespace osu.Game.Modes.Taiko.Objects.Drawable
{ {
protected override Key[] HitKeys { get; } = { Key.F, Key.J }; protected override Key[] HitKeys { get; } = { Key.F, Key.J };
private readonly CirclePiece circlePiece;
public DrawableStrongCentreHit(Hit hit) public DrawableStrongCentreHit(Hit hit)
: base(hit) : base(hit)
{ {
Add(circlePiece = new StrongCirclePiece
{
Children = new []
{
new CentreHitSymbolPiece()
}
});
} }
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(OsuColour colours) private void load(OsuColour colours)
{ {
circlePiece.AccentColour = colours.PinkDarker; Circle.AccentColour = colours.PinkDarker;
} }
protected override CirclePiece CreateCirclePiece() => new StrongCirclePiece
{
Children = new[] { new CentreHitSymbolPiece() }
};
} }
} }

View File

@ -12,24 +12,20 @@ namespace osu.Game.Modes.Taiko.Objects.Drawable
{ {
protected override Key[] HitKeys { get; } = { Key.D, Key.K }; protected override Key[] HitKeys { get; } = { Key.D, Key.K };
private readonly CirclePiece circlePiece;
public DrawableStrongRimHit(Hit hit) public DrawableStrongRimHit(Hit hit)
: base(hit) : base(hit)
{ {
Add(circlePiece = new StrongCirclePiece
{
Children = new[]
{
new RimHitSymbolPiece()
}
});
} }
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(OsuColour colours) private void load(OsuColour colours)
{ {
circlePiece.AccentColour = colours.BlueDarker; Circle.AccentColour = colours.BlueDarker;
} }
protected override CirclePiece CreateCirclePiece() => new StrongCirclePiece
{
Children = new[] { new RimHitSymbolPiece() }
};
} }
} }