1
0
mirror of https://github.com/ppy/osu.git synced 2025-02-15 04:12:57 +08:00

Merge pull request #8230 from EVAST9919/catcher-fix

Fix catcher showing miss sprite upon missing bananas
This commit is contained in:
Dean Herbert 2020-03-12 20:10:36 +09:00 committed by GitHub
commit cc8a413f6b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 49 additions and 16 deletions

View File

@ -4,7 +4,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using osu.Framework.Allocation; using NUnit.Framework;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Game.Beatmaps; using osu.Game.Beatmaps;
@ -34,8 +34,8 @@ namespace osu.Game.Rulesets.Catch.Tests
private DrawableCatchRuleset drawableRuleset; private DrawableCatchRuleset drawableRuleset;
private double playfieldTime => drawableRuleset.Playfield.Time.Current; private double playfieldTime => drawableRuleset.Playfield.Time.Current;
[BackgroundDependencyLoader] [SetUp]
private void load() public void Setup() => Schedule(() =>
{ {
var controlPointInfo = new ControlPointInfo(); var controlPointInfo = new ControlPointInfo();
controlPointInfo.Add(0, new TimingControlPoint()); controlPointInfo.Add(0, new TimingControlPoint());
@ -57,7 +57,7 @@ namespace osu.Game.Rulesets.Catch.Tests
ControlPointInfo = controlPointInfo ControlPointInfo = controlPointInfo
}); });
Add(new Container Child = new Container
{ {
Anchor = Anchor.Centre, Anchor = Anchor.Centre,
Origin = Anchor.Centre, Origin = Anchor.Centre,
@ -66,16 +66,49 @@ namespace osu.Game.Rulesets.Catch.Tests
{ {
drawableRuleset = new DrawableCatchRuleset(new CatchRuleset(), beatmap.GetPlayableBeatmap(new CatchRuleset().RulesetInfo)) drawableRuleset = new DrawableCatchRuleset(new CatchRuleset(), beatmap.GetPlayableBeatmap(new CatchRuleset().RulesetInfo))
} }
}); };
});
[Test]
public void TestFruits()
{
AddStep("hit fruits", () => spawnFruits(true));
AddUntilStep("wait for completion", () => playfieldIsEmpty);
AddAssert("catcher state is idle", () => catcherState == CatcherAnimationState.Idle);
AddStep("miss fruits", () => spawnFruits()); AddStep("miss fruits", () => spawnFruits());
AddStep("hit fruits", () => spawnFruits(true)); AddUntilStep("wait for completion", () => playfieldIsEmpty);
AddStep("miss juicestream", () => spawnJuiceStream()); AddAssert("catcher state is failed", () => catcherState == CatcherAnimationState.Fail);
AddStep("hit juicestream", () => spawnJuiceStream(true));
AddStep("miss bananas", () => spawnBananas());
AddStep("hit bananas", () => spawnBananas(true));
} }
[Test]
public void TestJuicestream()
{
AddStep("hit juicestream", () => spawnJuiceStream(true));
AddUntilStep("wait for completion", () => playfieldIsEmpty);
AddAssert("catcher state is idle", () => catcherState == CatcherAnimationState.Idle);
AddStep("miss juicestream", () => spawnJuiceStream());
AddUntilStep("wait for completion", () => playfieldIsEmpty);
AddAssert("catcher state is failed", () => catcherState == CatcherAnimationState.Fail);
}
[Test]
public void TestBananas()
{
AddStep("hit bananas", () => spawnBananas(true));
AddUntilStep("wait for completion", () => playfieldIsEmpty);
AddAssert("catcher state is idle", () => catcherState == CatcherAnimationState.Idle);
AddStep("miss bananas", () => spawnBananas());
AddUntilStep("wait for completion", () => playfieldIsEmpty);
AddAssert("catcher state is idle", () => catcherState == CatcherAnimationState.Idle);
}
private bool playfieldIsEmpty => !((CatchPlayfield)drawableRuleset.Playfield).AllHitObjects.Any(h => h.IsAlive);
private CatcherAnimationState catcherState => ((CatchPlayfield)drawableRuleset.Playfield).CatcherArea.MovableCatcher.CurrentState;
private void spawnFruits(bool hit = false) private void spawnFruits(bool hit = false)
{ {
for (int i = 1; i <= 4; i++) for (int i = 1; i <= 4; i++)

View File

@ -188,7 +188,7 @@ namespace osu.Game.Rulesets.Catch.UI
CatcherSprite current; CatcherSprite current;
switch (currentState) switch (CurrentState)
{ {
default: default:
current = catcherIdle; current = catcherIdle;
@ -274,7 +274,7 @@ namespace osu.Game.Rulesets.Catch.UI
return additive; return additive;
} }
private Drawable createCatcherSprite() => new CatcherSprite(currentState); private Drawable createCatcherSprite() => new CatcherSprite(CurrentState);
/// <summary> /// <summary>
/// Add a caught fruit to the catcher's stack. /// Add a caught fruit to the catcher's stack.
@ -344,7 +344,7 @@ namespace osu.Game.Rulesets.Catch.UI
if (validCatch) if (validCatch)
updateState(fruit.Kiai ? CatcherAnimationState.Kiai : CatcherAnimationState.Idle); updateState(fruit.Kiai ? CatcherAnimationState.Kiai : CatcherAnimationState.Idle);
else else if (!(fruit is Banana))
updateState(CatcherAnimationState.Fail); updateState(CatcherAnimationState.Fail);
return validCatch; return validCatch;
@ -352,14 +352,14 @@ namespace osu.Game.Rulesets.Catch.UI
private void updateState(CatcherAnimationState state) private void updateState(CatcherAnimationState state)
{ {
if (currentState == state) if (CurrentState == state)
return; return;
currentState = state; CurrentState = state;
updateCatcher(); updateCatcher();
} }
private CatcherAnimationState currentState; public CatcherAnimationState CurrentState { get; private set; }
private double hyperDashModifier = 1; private double hyperDashModifier = 1;
private int hyperDashDirection; private int hyperDashDirection;