diff --git a/osu.Desktop.VisualTests/Tests/TestCaseTaikoHitObjects.cs b/osu.Desktop.VisualTests/Tests/TestCaseTaikoHitObjects.cs index 4eba9e6a96..5d6ab9bd1a 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseTaikoHitObjects.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseTaikoHitObjects.cs @@ -6,10 +6,8 @@ using OpenTK.Graphics; using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; -using osu.Framework.Graphics.Sprites; using osu.Framework.Testing; using osu.Game.Graphics; -using osu.Game.Modes.Taiko.Objects; using osu.Game.Modes.Taiko.Objects.Drawable.Pieces; namespace osu.Desktop.VisualTests.Tests @@ -30,39 +28,55 @@ namespace osu.Desktop.VisualTests.Tests Reset(); }); - Add(new CentreHitCircle(new CirclePiece() + Add(new CirclePiece { - KiaiMode = kiai - }) - { - Position = new Vector2(100, 100) + Position = new Vector2(100, 100), + Width = 0, + AccentColour = Color4.DarkRed, + KiaiMode = kiai, + Children = new[] + { + new CentreHitSymbolPiece() + } }); - Add(new CentreHitCircle(new StrongCirclePiece() + Add(new StrongCirclePiece { - KiaiMode = kiai - }) - { - Position = new Vector2(350, 100) + Position = new Vector2(350, 100), + Width = 0, + AccentColour = Color4.DarkRed, + KiaiMode = kiai, + Children = new[] + { + new CentreHitSymbolPiece() + } }); - Add(new RimHitCircle(new CirclePiece() + Add(new CirclePiece { - KiaiMode = kiai - }) - { - Position = new Vector2(100, 300) + Position = new Vector2(100, 300), + Width = 0, + AccentColour = Color4.DarkBlue, + KiaiMode = kiai, + Children = new[] + { + new RimHitSymbolPiece() + } }); - Add(new RimHitCircle(new StrongCirclePiece() + Add(new StrongCirclePiece { - KiaiMode = kiai - }) - { - Position = new Vector2(350, 300) + Position = new Vector2(350, 300), + Width = 0, + AccentColour = Color4.DarkBlue, + KiaiMode = kiai, + Children = new[] + { + new RimHitSymbolPiece() + } }); - Add(new SwellCircle(new CirclePiece() + Add(new SwellCircle(new CirclePiece { KiaiMode = kiai }) @@ -70,7 +84,7 @@ namespace osu.Desktop.VisualTests.Tests Position = new Vector2(100, 500) }); - Add(new SwellCircle(new StrongCirclePiece() + Add(new SwellCircle(new StrongCirclePiece { KiaiMode = kiai }) @@ -78,7 +92,7 @@ namespace osu.Desktop.VisualTests.Tests Position = new Vector2(350, 500) }); - Add(new DrumRollCircle(new CirclePiece() + Add(new DrumRollCircle(new CirclePiece { KiaiMode = kiai }) @@ -87,7 +101,7 @@ namespace osu.Desktop.VisualTests.Tests Position = new Vector2(575, 100) }); - Add(new DrumRollCircle(new StrongCirclePiece() + Add(new DrumRollCircle(new StrongCirclePiece { KiaiMode = kiai }) @@ -106,7 +120,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,72 +147,8 @@ 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) - : base(piece) - { - Piece.Add(new CircularContainer - { - Anchor = Anchor.Centre, - Origin = Anchor.Centre, - Size = new Vector2(SYMBOL_SIZE), - BorderThickness = SYMBOL_BORDER, - BorderColour = Color4.White, - Masking = true, - Children = new[] - { - new Box - { - RelativeSizeAxes = Axes.Both, - Alpha = 0, - AlwaysPresent = true - } - } - }); - } - - [BackgroundDependencyLoader] - private void load(OsuColour colours) - { - Piece.AccentColour = colours.BlueDarker; - } - } - 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) diff --git a/osu.Desktop.VisualTests/Tests/TestCaseTaikoPlayfield.cs b/osu.Desktop.VisualTests/Tests/TestCaseTaikoPlayfield.cs index 5a988c54e1..a6491bd07b 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseTaikoPlayfield.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseTaikoPlayfield.cs @@ -1,11 +1,15 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Primitives; using osu.Framework.MathUtils; using osu.Framework.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,10 +26,20 @@ namespace osu.Desktop.VisualTests.Tests AddButton("Hit!", addHitJudgement); AddButton("Miss :(", addMissJudgement); + AddButton("Centre", () => addCentreHit(false)); + AddButton("Strong Centre", () => addCentreHit(true)); + AddButton("Rim", () => addRimHit(false)); + AddButton("Strong Rim", () => addRimHit(true)); - Add(playfield = new TaikoPlayfield + Add(new Container { - Y = 200 + RelativeSizeAxes = Axes.X, + Y = 200, + Padding = new MarginPadding { Left = 200 }, + Children = new[] + { + playfield = new TaikoPlayfield() + } }); } @@ -60,6 +74,34 @@ namespace osu.Desktop.VisualTests.Tests }); } + private void addCentreHit(bool strong) + { + Hit h = new Hit + { + StartTime = Time.Current + 1000, + PreEmpt = 1000 + }; + + if (strong) + playfield.Add(new DrawableStrongCentreHit(h)); + else + playfield.Add(new DrawableCentreHit(h)); + } + + private void addRimHit(bool strong) + { + Hit h = new Hit + { + StartTime = Time.Current + 1000, + PreEmpt = 1000 + }; + + if (strong) + playfield.Add(new DrawableStrongRimHit(h)); + else + playfield.Add(new DrawableRimHit(h)); + } + private class DrawableTestHit : DrawableHitObject { public DrawableTestHit(TaikoHitObject hitObject) diff --git a/osu.Game.Modes.Taiko/Objects/Drawable/DrawableCentreHit.cs b/osu.Game.Modes.Taiko/Objects/Drawable/DrawableCentreHit.cs new file mode 100644 index 0000000000..683d48df10 --- /dev/null +++ b/osu.Game.Modes.Taiko/Objects/Drawable/DrawableCentreHit.cs @@ -0,0 +1,35 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using OpenTK.Input; +using osu.Game.Modes.Taiko.Objects.Drawable.Pieces; +using osu.Game.Graphics; +using osu.Framework.Allocation; + +namespace osu.Game.Modes.Taiko.Objects.Drawable +{ + public class DrawableCentreHit : DrawableHit + { + protected override Key[] HitKeys { get; } = { Key.F, Key.J }; + + private readonly CirclePiece circlePiece; + + public DrawableCentreHit(Hit hit) + : base(hit) + { + Add(circlePiece = new CirclePiece + { + Children = new[] + { + new CentreHitSymbolPiece() + } + }); + } + + [BackgroundDependencyLoader] + private void load(OsuColour colours) + { + circlePiece.AccentColour = colours.PinkDarker; + } + } +} diff --git a/osu.Game.Modes.Taiko/Objects/Drawable/DrawableHit.cs b/osu.Game.Modes.Taiko/Objects/Drawable/DrawableHit.cs index a3ea9e36b9..ae328fe9ca 100644 --- a/osu.Game.Modes.Taiko/Objects/Drawable/DrawableHit.cs +++ b/osu.Game.Modes.Taiko/Objects/Drawable/DrawableHit.cs @@ -2,10 +2,12 @@ // 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.Game.Modes.Objects.Drawables; using osu.Game.Modes.Taiko.Judgements; using System; -using System.Collections.Generic; +using System.Linq; namespace osu.Game.Modes.Taiko.Objects.Drawable { @@ -14,7 +16,9 @@ namespace osu.Game.Modes.Taiko.Objects.Drawable /// /// A list of keys which can result in hits for this HitObject. /// - protected abstract List HitKeys { get; } + protected abstract Key[] HitKeys { get; } + + protected override Container Content => bodyContainer; private readonly Hit hit; @@ -23,10 +27,18 @@ namespace osu.Game.Modes.Taiko.Objects.Drawable /// private bool validKeyPressed; + private readonly Container bodyContainer; + protected DrawableHit(Hit hit) : base(hit) { this.hit = hit; + + AddInternal(bodyContainer = new Container + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + }); } protected override void CheckJudgement(bool userTriggered) @@ -63,5 +75,30 @@ namespace osu.Game.Modes.Taiko.Objects.Drawable return UpdateJudgement(true); } + + protected override void UpdateState(ArmedState state) + { + Delay(HitObject.StartTime - Time.Current + Judgement.TimeOffset, true); + + switch (State) + { + case ArmedState.Idle: + Delay(hit.HitWindowMiss); + break; + case ArmedState.Miss: + FadeOut(100); + break; + case ArmedState.Hit: + bodyContainer.ScaleTo(0.8f, 400, EasingTypes.OutQuad); + bodyContainer.MoveToY(-200, 250, EasingTypes.Out); + bodyContainer.Delay(250); + bodyContainer.MoveToY(0, 500, EasingTypes.In); + + FadeOut(600); + break; + } + + Expire(); + } } } diff --git a/osu.Game.Modes.Taiko/Objects/Drawable/DrawableRimHit.cs b/osu.Game.Modes.Taiko/Objects/Drawable/DrawableRimHit.cs new file mode 100644 index 0000000000..cab6819300 --- /dev/null +++ b/osu.Game.Modes.Taiko/Objects/Drawable/DrawableRimHit.cs @@ -0,0 +1,35 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using osu.Framework.Allocation; +using osu.Game.Graphics; +using OpenTK.Input; +using osu.Game.Modes.Taiko.Objects.Drawable.Pieces; + +namespace osu.Game.Modes.Taiko.Objects.Drawable +{ + public class DrawableRimHit : DrawableHit + { + protected override Key[] HitKeys { get; } = { Key.D, Key.K }; + + private readonly CirclePiece circlePiece; + + public DrawableRimHit(Hit hit) + : base(hit) + { + Add(circlePiece = new CirclePiece + { + Children = new[] + { + new RimHitSymbolPiece() + } + }); + } + + [BackgroundDependencyLoader] + private void load(OsuColour colours) + { + circlePiece.AccentColour = colours.BlueDarker; + } + } +} diff --git a/osu.Game.Modes.Taiko/Objects/Drawable/DrawableStrongCentreHit.cs b/osu.Game.Modes.Taiko/Objects/Drawable/DrawableStrongCentreHit.cs new file mode 100644 index 0000000000..b4ec0b108a --- /dev/null +++ b/osu.Game.Modes.Taiko/Objects/Drawable/DrawableStrongCentreHit.cs @@ -0,0 +1,35 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using OpenTK.Input; +using osu.Game.Modes.Taiko.Objects.Drawable.Pieces; +using osu.Framework.Allocation; +using osu.Game.Graphics; + +namespace osu.Game.Modes.Taiko.Objects.Drawable +{ + public class DrawableStrongCentreHit : DrawableStrongHit + { + protected override Key[] HitKeys { get; } = { Key.F, Key.J }; + + private readonly CirclePiece circlePiece; + + public DrawableStrongCentreHit(Hit hit) + : base(hit) + { + Add(circlePiece = new StrongCirclePiece + { + Children = new [] + { + new CentreHitSymbolPiece() + } + }); + } + + [BackgroundDependencyLoader] + private void load(OsuColour colours) + { + circlePiece.AccentColour = colours.PinkDarker; + } + } +} diff --git a/osu.Game.Modes.Taiko/Objects/Drawable/DrawableStrongRimHit.cs b/osu.Game.Modes.Taiko/Objects/Drawable/DrawableStrongRimHit.cs new file mode 100644 index 0000000000..1f77ad0409 --- /dev/null +++ b/osu.Game.Modes.Taiko/Objects/Drawable/DrawableStrongRimHit.cs @@ -0,0 +1,35 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using osu.Framework.Allocation; +using osu.Game.Graphics; +using OpenTK.Input; +using osu.Game.Modes.Taiko.Objects.Drawable.Pieces; + +namespace osu.Game.Modes.Taiko.Objects.Drawable +{ + public class DrawableStrongRimHit : DrawableStrongHit + { + protected override Key[] HitKeys { get; } = { Key.D, Key.K }; + + private readonly CirclePiece circlePiece; + + public DrawableStrongRimHit(Hit hit) + : base(hit) + { + Add(circlePiece = new StrongCirclePiece + { + Children = new[] + { + new RimHitSymbolPiece() + } + }); + } + + [BackgroundDependencyLoader] + private void load(OsuColour colours) + { + circlePiece.AccentColour = colours.BlueDarker; + } + } +} diff --git a/osu.Game.Modes.Taiko/Objects/Drawable/DrawableTaikoHitObject.cs b/osu.Game.Modes.Taiko/Objects/Drawable/DrawableTaikoHitObject.cs index c14dc6d7b0..5d6d669dc1 100644 --- a/osu.Game.Modes.Taiko/Objects/Drawable/DrawableTaikoHitObject.cs +++ b/osu.Game.Modes.Taiko/Objects/Drawable/DrawableTaikoHitObject.cs @@ -30,7 +30,6 @@ namespace osu.Game.Modes.Taiko.Objects.Drawable protected override void LoadComplete() { LifetimeStart = HitObject.StartTime - HitObject.PreEmpt * 2; - LifetimeEnd = HitObject.StartTime + HitObject.PreEmpt; base.LoadComplete(); } diff --git a/osu.Game.Modes.Taiko/Objects/Drawable/Pieces/CentreHitSymbolPiece.cs b/osu.Game.Modes.Taiko/Objects/Drawable/Pieces/CentreHitSymbolPiece.cs new file mode 100644 index 0000000000..e62ca6b073 --- /dev/null +++ b/osu.Game.Modes.Taiko/Objects/Drawable/Pieces/CentreHitSymbolPiece.cs @@ -0,0 +1,31 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Sprites; +using OpenTK; + +namespace osu.Game.Modes.Taiko.Objects.Drawable.Pieces +{ + /// + /// The symbol used for centre hit pieces. + /// + public class CentreHitSymbolPiece : CircularContainer + { + public CentreHitSymbolPiece() + { + Anchor = Anchor.Centre; + Origin = Anchor.Centre; + Size = new Vector2(CirclePiece.SYMBOL_INNER_SIZE); + Masking = true; + Children = new[] + { + new Box + { + RelativeSizeAxes = Axes.Both + } + }; + } + } +} diff --git a/osu.Game.Modes.Taiko/Objects/Drawable/Pieces/RimHitSymbolPiece.cs b/osu.Game.Modes.Taiko/Objects/Drawable/Pieces/RimHitSymbolPiece.cs new file mode 100644 index 0000000000..6999634108 --- /dev/null +++ b/osu.Game.Modes.Taiko/Objects/Drawable/Pieces/RimHitSymbolPiece.cs @@ -0,0 +1,36 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Sprites; +using OpenTK; +using OpenTK.Graphics; + +namespace osu.Game.Modes.Taiko.Objects.Drawable.Pieces +{ + /// + /// The symbol used for rim hit pieces. + /// + public class RimHitSymbolPiece : CircularContainer + { + public RimHitSymbolPiece() + { + Anchor = Anchor.Centre; + Origin = Anchor.Centre; + Size = new Vector2(CirclePiece.SYMBOL_SIZE); + BorderThickness = CirclePiece.SYMBOL_BORDER; + BorderColour = Color4.White; + Masking = true; + Children = new[] + { + new Box + { + RelativeSizeAxes = Axes.Both, + Alpha = 0, + AlwaysPresent = true + } + }; + } + } +} diff --git a/osu.Game.Modes.Taiko/osu.Game.Modes.Taiko.csproj b/osu.Game.Modes.Taiko/osu.Game.Modes.Taiko.csproj index d2aecc8d2e..07f9a5d4e6 100644 --- a/osu.Game.Modes.Taiko/osu.Game.Modes.Taiko.csproj +++ b/osu.Game.Modes.Taiko/osu.Game.Modes.Taiko.csproj @@ -52,12 +52,18 @@ + + + + + + @@ -102,4 +108,4 @@ --> - + \ No newline at end of file diff --git a/osu.Game.Modes.Taiko/packages.config b/osu.Game.Modes.Taiko/packages.config index 08fca09c35..4031dd62a8 100644 --- a/osu.Game.Modes.Taiko/packages.config +++ b/osu.Game.Modes.Taiko/packages.config @@ -1,5 +1,4 @@  -