1
0
mirror of https://github.com/ppy/osu.git synced 2025-02-16 03:42:54 +08:00

Add drawable Hits/StrongHits.

This commit is contained in:
smoogipooo 2017-03-28 10:33:23 +09:00
parent 2211c08441
commit 621bcaed59
7 changed files with 136 additions and 37 deletions

View File

@ -10,6 +10,7 @@ using osu.Framework.Graphics.Sprites;
using osu.Framework.Screens.Testing;
using osu.Game.Graphics;
using osu.Game.Modes.Taiko.Objects;
using osu.Game.Modes.Taiko.Objects.Drawable;
using osu.Game.Modes.Taiko.Objects.Drawable.Pieces;
namespace osu.Desktop.VisualTests.Tests
@ -30,7 +31,7 @@ namespace osu.Desktop.VisualTests.Tests
Reset();
});
Add(new CentreHitCircle(new CirclePiece()
Add(new CentreHitCirclePiece(new CirclePiece()
{
KiaiMode = kiai
})
@ -38,7 +39,7 @@ namespace osu.Desktop.VisualTests.Tests
Position = new Vector2(100, 100)
});
Add(new CentreHitCircle(new StrongCirclePiece()
Add(new CentreHitCirclePiece(new StrongCirclePiece()
{
KiaiMode = kiai
})
@ -106,7 +107,7 @@ namespace osu.Desktop.VisualTests.Tests
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
TextSize = SYMBOL_INNER_SIZE,
TextSize = CirclePiece.SYMBOL_INNER_SIZE,
Icon = FontAwesome.fa_asterisk,
Shadow = false
});
@ -133,34 +134,6 @@ namespace osu.Desktop.VisualTests.Tests
}
}
private class CentreHitCircle : BaseCircle
{
public CentreHitCircle(CirclePiece piece)
: base(piece)
{
Piece.Add(new CircularContainer
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Size = new Vector2(SYMBOL_INNER_SIZE),
Masking = true,
Children = new[]
{
new Box
{
RelativeSizeAxes = Axes.Both
}
}
});
}
[BackgroundDependencyLoader]
private void load(OsuColour colours)
{
Piece.AccentColour = colours.PinkDarker;
}
}
private class RimHitCircle : BaseCircle
{
public RimHitCircle(CirclePiece piece)
@ -170,8 +143,8 @@ namespace osu.Desktop.VisualTests.Tests
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Size = new Vector2(SYMBOL_SIZE),
BorderThickness = SYMBOL_BORDER,
Size = new Vector2(CirclePiece.SYMBOL_SIZE),
BorderThickness = CirclePiece.SYMBOL_BORDER,
BorderColour = Color4.White,
Masking = true,
Children = new[]
@ -195,10 +168,6 @@ namespace osu.Desktop.VisualTests.Tests
private abstract class BaseCircle : Container
{
protected const float SYMBOL_SIZE = TaikoHitObject.CIRCLE_RADIUS * 2f * 0.45f;
protected const float SYMBOL_BORDER = 8;
protected const float SYMBOL_INNER_SIZE = SYMBOL_SIZE - 2 * SYMBOL_BORDER;
protected readonly CirclePiece Piece;
protected BaseCircle(CirclePiece piece)

View File

@ -6,6 +6,7 @@ using osu.Framework.Screens.Testing;
using osu.Game.Modes.Objects.Drawables;
using osu.Game.Modes.Taiko.Judgements;
using osu.Game.Modes.Taiko.Objects;
using osu.Game.Modes.Taiko.Objects.Drawable;
using osu.Game.Modes.Taiko.UI;
namespace osu.Desktop.VisualTests.Tests
@ -22,6 +23,15 @@ namespace osu.Desktop.VisualTests.Tests
AddButton("Hit!", addHitJudgement);
AddButton("Miss :(", addMissJudgement);
AddButton("Centre", () =>
{
playfield.Add(new DrawableCentreHit(new Hit
{
StartTime = Time.Current + 1000,
PreEmpt = 1000,
IsStrong = false
}));
});
Add(playfield = new TaikoPlayfield
{

View File

@ -0,0 +1,49 @@
using OpenTK;
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Sprites;
using osu.Game.Graphics;
using osu.Game.Modes.Taiko.Objects.Drawable.Pieces;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace osu.Game.Modes.Taiko.Objects.Drawable
{
/// <summary>
/// A circle piece used for centre hits.
/// </summary>
public class CentreHitCirclePiece : Container
{
private CirclePiece circle;
public CentreHitCirclePiece(CirclePiece piece)
{
Add(circle = piece);
circle.Add(new CircularContainer
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Size = new Vector2(CirclePiece.SYMBOL_INNER_SIZE),
Masking = true,
Children = new[]
{
new Box
{
RelativeSizeAxes = Axes.Both
}
}
});
}
[BackgroundDependencyLoader]
private void load(OsuColour colours)
{
circle.AccentColour = colours.PinkDarker;
}
}
}

View File

@ -0,0 +1,17 @@
using System.Collections.Generic;
using OpenTK.Input;
using osu.Game.Modes.Taiko.Objects.Drawable.Pieces;
namespace osu.Game.Modes.Taiko.Objects.Drawable
{
public class DrawableCentreHit : DrawableHit
{
protected override List<Key> HitKeys { get; } = new List<Key>(new Key[] { Key.F, Key.J });
public DrawableCentreHit(Hit hit)
: base(hit)
{
Add(new CentreHitCirclePiece(new CirclePiece()));
}
}
}

View File

@ -2,6 +2,9 @@
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using OpenTK.Input;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Transforms;
using osu.Game.Modes.Objects.Drawables;
using osu.Game.Modes.Taiko.Judgements;
using System;
@ -16,6 +19,8 @@ namespace osu.Game.Modes.Taiko.Objects.Drawable
/// </summary>
protected abstract List<Key> HitKeys { get; }
protected override Container<Framework.Graphics.Drawable> Content => bodyContainer;
private readonly Hit hit;
/// <summary>
@ -23,10 +28,18 @@ namespace osu.Game.Modes.Taiko.Objects.Drawable
/// </summary>
private bool validKeyPressed;
private Container bodyContainer;
protected DrawableHit(Hit hit)
: base(hit)
{
this.hit = hit;
AddInternal(bodyContainer = new Container
{
Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreLeft,
});
}
protected override void CheckJudgement(bool userTriggered)
@ -63,5 +76,26 @@ namespace osu.Game.Modes.Taiko.Objects.Drawable
return UpdateJudgement(true);
}
protected override void UpdateState(ArmedState state)
{
switch (State)
{
case ArmedState.Idle:
break;
case ArmedState.Miss:
bodyContainer.FadeOut(100);
break;
case ArmedState.Hit:
bodyContainer.ScaleTo(0.8f, 400, EasingTypes.OutQuad);
bodyContainer.FadeOut(600, EasingTypes.OutQuint);
bodyContainer.MoveToY(-200, 250, EasingTypes.Out);
bodyContainer.Delay(250);
bodyContainer.MoveToY(0, 500, EasingTypes.In);
break;
}
}
}
}

View File

@ -0,0 +1,17 @@
using System.Collections.Generic;
using OpenTK.Input;
using osu.Game.Modes.Taiko.Objects.Drawable.Pieces;
namespace osu.Game.Modes.Taiko.Objects.Drawable
{
public class DrawableStrongCentreHit : DrawableStrongHit
{
protected override List<Key> HitKeys { get; } = new List<Key>(new Key[] { Key.F, Key.J });
public DrawableStrongCentreHit(Hit hit)
: base(hit)
{
Add(new CentreHitCirclePiece(new StrongCirclePiece()));
}
}
}

View File

@ -52,7 +52,10 @@
<Compile Include="Judgements\TaikoDrumRollTickJudgement.cs" />
<Compile Include="Judgements\TaikoJudgement.cs" />
<Compile Include="Judgements\TaikoHitResult.cs" />
<Compile Include="Objects\Drawable\CentreHitCirclePiece.cs" />
<Compile Include="Objects\Drawable\DrawableCentreHit.cs" />
<Compile Include="Objects\Drawable\DrawableHit.cs" />
<Compile Include="Objects\Drawable\DrawableStrongCentreHit.cs" />
<Compile Include="Objects\Drawable\DrawableStrongHit.cs" />
<Compile Include="Objects\Drawable\Pieces\StrongCirclePiece.cs" />
<Compile Include="Objects\Drawable\DrawableSwell.cs" />