1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 12:17:26 +08:00

Merge pull request #21379 from Joppe27/taiko-animations-recovered

Add taiko hit overlay animations
This commit is contained in:
Dean Herbert 2022-11-23 15:09:44 +09:00 committed by GitHub
commit 23f91ec717
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 120 additions and 63 deletions

View File

@ -26,8 +26,10 @@ namespace osu.Game.Rulesets.Taiko.Tests.Skinning
}; };
[Test] [Test]
public void DrumrollTest() public void TestDrumroll([Values] bool withKiai)
{ {
AddStep("set up beatmap", () => setUpBeatmap(withKiai));
AddStep("Drum roll", () => SetContents(_ => AddStep("Drum roll", () => SetContents(_ =>
{ {
var hoc = new ScrollingHitObjectContainer(); var hoc = new ScrollingHitObjectContainer();
@ -73,5 +75,22 @@ namespace osu.Game.Rulesets.Taiko.Tests.Skinning
return drumroll; return drumroll;
} }
private void setUpBeatmap(bool withKiai)
{
var controlPointInfo = new ControlPointInfo();
controlPointInfo.Add(0, new TimingControlPoint { BeatLength = 500 });
if (withKiai)
controlPointInfo.Add(0, new EffectControlPoint { KiaiMode = true });
Beatmap.Value = CreateWorkingBeatmap(new Beatmap
{
ControlPointInfo = controlPointInfo
});
Beatmap.Value.Track.Start();
}
} }
} }

View File

@ -1,30 +0,0 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using NUnit.Framework;
using osu.Game.Beatmaps.ControlPoints;
using osu.Game.Beatmaps;
namespace osu.Game.Rulesets.Taiko.Tests.Skinning
{
[TestFixture]
public class TestSceneDrawableDrumRollKiai : TestSceneDrawableDrumRoll
{
[SetUp]
public void SetUp() => Schedule(() =>
{
var controlPointInfo = new ControlPointInfo();
controlPointInfo.Add(0, new TimingControlPoint { BeatLength = 500 });
controlPointInfo.Add(0, new EffectControlPoint { KiaiMode = true });
Beatmap.Value = CreateWorkingBeatmap(new Beatmap
{
ControlPointInfo = controlPointInfo
});
// track needs to be playing for BeatSyncedContainer to work.
Beatmap.Value.Track.Start();
});
}
}

View File

@ -4,19 +4,51 @@
#nullable disable #nullable disable
using NUnit.Framework; using NUnit.Framework;
using osu.Framework.Allocation;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Game.Beatmaps; using osu.Game.Beatmaps;
using osu.Game.Beatmaps.ControlPoints; using osu.Game.Beatmaps.ControlPoints;
using osu.Game.Rulesets.Taiko.Objects; using osu.Game.Rulesets.Taiko.Objects;
using osu.Game.Rulesets.Taiko.Objects.Drawables; using osu.Game.Rulesets.Taiko.Objects.Drawables;
using osu.Game.Screens.Play;
using osu.Game.Tests.Gameplay;
namespace osu.Game.Rulesets.Taiko.Tests.Skinning namespace osu.Game.Rulesets.Taiko.Tests.Skinning
{ {
[TestFixture] [TestFixture]
public class TestSceneDrawableHit : TaikoSkinnableTestScene public class TestSceneDrawableHit : TaikoSkinnableTestScene
{ {
[Cached]
private GameplayState gameplayState = TestGameplayState.Create(new TaikoRuleset());
[Test] [Test]
public void TestHits() public void TestHits([Values] bool withKiai)
{
AddStep("Create beatmap", () => setUpBeatmap(withKiai));
addHitSteps();
}
[Test]
public void TestHitAnimationSlow()
{
AddStep("Create beatmap", () => setUpBeatmap(false));
AddStep("Set 50 combo", () => gameplayState.ScoreProcessor.Combo.Value = 50);
addHitSteps();
AddStep("Reset combo", () => gameplayState.ScoreProcessor.Combo.Value = 0);
}
[Test]
public void TestHitAnimationFast()
{
AddStep("Create beatmap", () => setUpBeatmap(false));
AddStep("Set 150 combo", () => gameplayState.ScoreProcessor.Combo.Value = 150);
addHitSteps();
AddStep("Reset combo", () => gameplayState.ScoreProcessor.Combo.Value = 0);
}
private void addHitSteps()
{ {
AddStep("Centre hit", () => SetContents(_ => new DrawableHit(createHitAtCurrentTime()) AddStep("Centre hit", () => SetContents(_ => new DrawableHit(createHitAtCurrentTime())
{ {
@ -56,5 +88,22 @@ namespace osu.Game.Rulesets.Taiko.Tests.Skinning
return hit; return hit;
} }
private void setUpBeatmap(bool withKiai)
{
var controlPointInfo = new ControlPointInfo();
controlPointInfo.Add(0, new TimingControlPoint { BeatLength = 500 });
if (withKiai)
controlPointInfo.Add(0, new EffectControlPoint { KiaiMode = true });
Beatmap.Value = CreateWorkingBeatmap(new Beatmap
{
ControlPointInfo = controlPointInfo
});
Beatmap.Value.Track.Start();
}
} }
} }

View File

@ -1,30 +0,0 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using NUnit.Framework;
using osu.Game.Beatmaps;
using osu.Game.Beatmaps.ControlPoints;
namespace osu.Game.Rulesets.Taiko.Tests.Skinning
{
[TestFixture]
public class TestSceneDrawableHitKiai : TestSceneDrawableHit
{
[SetUp]
public void SetUp() => Schedule(() =>
{
var controlPointInfo = new ControlPointInfo();
controlPointInfo.Add(0, new TimingControlPoint { BeatLength = 500 });
controlPointInfo.Add(0, new EffectControlPoint { KiaiMode = true });
Beatmap.Value = CreateWorkingBeatmap(new Beatmap
{
ControlPointInfo = controlPointInfo
});
// track needs to be playing for BeatSyncedContainer to work.
Beatmap.Value.Track.Start();
});
}
}

View File

@ -2,13 +2,16 @@
// See the LICENCE file in the repository root for full licence text. // See the LICENCE file in the repository root for full licence text.
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Animations; using osu.Framework.Graphics.Animations;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Primitives; using osu.Framework.Graphics.Primitives;
using osu.Game.Beatmaps;
using osu.Game.Graphics; using osu.Game.Graphics;
using osu.Game.Rulesets.Objects.Drawables; using osu.Game.Rulesets.Objects.Drawables;
using osu.Game.Rulesets.Taiko.Objects; using osu.Game.Rulesets.Taiko.Objects;
using osu.Game.Screens.Play;
using osu.Game.Skinning; using osu.Game.Skinning;
using osuTK; using osuTK;
using osuTK.Graphics; using osuTK.Graphics;
@ -18,6 +21,12 @@ namespace osu.Game.Rulesets.Taiko.Skinning.Legacy
public class LegacyCirclePiece : CompositeDrawable, IHasAccentColour public class LegacyCirclePiece : CompositeDrawable, IHasAccentColour
{ {
private Drawable backgroundLayer = null!; private Drawable backgroundLayer = null!;
private Drawable? foregroundLayer;
private Bindable<int> currentCombo { get; } = new BindableInt();
private int animationFrame;
private double beatLength;
// required for editor blueprints (not sure why these circle pieces are zero size). // required for editor blueprints (not sure why these circle pieces are zero size).
public override Quad ScreenSpaceDrawQuad => backgroundLayer.ScreenSpaceDrawQuad; public override Quad ScreenSpaceDrawQuad => backgroundLayer.ScreenSpaceDrawQuad;
@ -27,6 +36,12 @@ namespace osu.Game.Rulesets.Taiko.Skinning.Legacy
RelativeSizeAxes = Axes.Both; RelativeSizeAxes = Axes.Both;
} }
[Resolved(canBeNull: true)]
private GameplayState? gameplayState { get; set; }
[Resolved(canBeNull: true)]
private IBeatSyncProvider? beatSyncProvider { get; set; }
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(ISkinSource skin, DrawableHitObject drawableHitObject) private void load(ISkinSource skin, DrawableHitObject drawableHitObject)
{ {
@ -45,7 +60,7 @@ namespace osu.Game.Rulesets.Taiko.Skinning.Legacy
// backgroundLayer is guaranteed to exist due to the pre-check in TaikoLegacySkinTransformer. // backgroundLayer is guaranteed to exist due to the pre-check in TaikoLegacySkinTransformer.
AddInternal(backgroundLayer = new LegacyKiaiFlashingDrawable(() => getDrawableFor("circle"))); AddInternal(backgroundLayer = new LegacyKiaiFlashingDrawable(() => getDrawableFor("circle")));
var foregroundLayer = getDrawableFor("circleoverlay"); foregroundLayer = getDrawableFor("circleoverlay");
if (foregroundLayer != null) if (foregroundLayer != null)
AddInternal(foregroundLayer); AddInternal(foregroundLayer);
@ -58,6 +73,9 @@ namespace osu.Game.Rulesets.Taiko.Skinning.Legacy
c.Anchor = Anchor.Centre; c.Anchor = Anchor.Centre;
c.Origin = Anchor.Centre; c.Origin = Anchor.Centre;
} }
if (gameplayState != null)
currentCombo.BindTo(gameplayState.ScoreProcessor.Combo);
} }
protected override void LoadComplete() protected override void LoadComplete()
@ -74,6 +92,37 @@ namespace osu.Game.Rulesets.Taiko.Skinning.Legacy
// This ensures they are scaled relative to each other but also match the expected DrawableHit size. // This ensures they are scaled relative to each other but also match the expected DrawableHit size.
foreach (var c in InternalChildren) foreach (var c in InternalChildren)
c.Scale = new Vector2(DrawHeight / 128); c.Scale = new Vector2(DrawHeight / 128);
if (foregroundLayer is IFramedAnimation animatableForegroundLayer)
animateForegroundLayer(animatableForegroundLayer);
}
private void animateForegroundLayer(IFramedAnimation animatableForegroundLayer)
{
int multiplier;
if (currentCombo.Value >= 150)
{
multiplier = 2;
}
else if (currentCombo.Value >= 50)
{
multiplier = 1;
}
else
{
animatableForegroundLayer.GotoFrame(0);
return;
}
if (beatSyncProvider?.ControlPoints != null)
{
beatLength = beatSyncProvider.ControlPoints.TimingPointAt(Time.Current).BeatLength;
animationFrame = Time.Current % ((beatLength * 2) / multiplier) >= beatLength / multiplier ? 0 : 1;
animatableForegroundLayer.GotoFrame(animationFrame);
}
} }
private Color4 accentColour; private Color4 accentColour;