mirror of
https://github.com/ppy/osu.git
synced 2025-01-06 09:03:01 +08:00
Fix hit lighting colour not applied in TestSceneCatcher
This commit is contained in:
parent
94a59ac3b2
commit
ed50fd445e
@ -18,6 +18,7 @@ using osu.Game.Rulesets.Catch.Objects;
|
|||||||
using osu.Game.Rulesets.Catch.Objects.Drawables;
|
using osu.Game.Rulesets.Catch.Objects.Drawables;
|
||||||
using osu.Game.Rulesets.Judgements;
|
using osu.Game.Rulesets.Judgements;
|
||||||
using osu.Game.Rulesets.Scoring;
|
using osu.Game.Rulesets.Scoring;
|
||||||
|
using osu.Game.Skinning;
|
||||||
using osu.Game.Tests.Visual;
|
using osu.Game.Tests.Visual;
|
||||||
|
|
||||||
namespace osu.Game.Rulesets.Catch.Tests
|
namespace osu.Game.Rulesets.Catch.Tests
|
||||||
@ -65,13 +66,11 @@ namespace osu.Game.Rulesets.Catch.Tests
|
|||||||
JudgementResult result2 = null;
|
JudgementResult result2 = null;
|
||||||
AddStep("catch hyper fruit", () =>
|
AddStep("catch hyper fruit", () =>
|
||||||
{
|
{
|
||||||
drawableObject1 = createDrawableObject(new Fruit { HyperDashTarget = new Fruit { X = 100 } });
|
attemptCatch(new Fruit { HyperDashTarget = new Fruit { X = 100 } }, out drawableObject1, out result1);
|
||||||
result1 = attemptCatch(drawableObject1);
|
|
||||||
});
|
});
|
||||||
AddStep("catch normal fruit", () =>
|
AddStep("catch normal fruit", () =>
|
||||||
{
|
{
|
||||||
drawableObject2 = createDrawableObject(new Fruit());
|
attemptCatch(new Fruit(), out drawableObject2, out result2);
|
||||||
result2 = attemptCatch(drawableObject2);
|
|
||||||
});
|
});
|
||||||
AddStep("revert second result", () =>
|
AddStep("revert second result", () =>
|
||||||
{
|
{
|
||||||
@ -92,8 +91,7 @@ namespace osu.Game.Rulesets.Catch.Tests
|
|||||||
JudgementResult result = null;
|
JudgementResult result = null;
|
||||||
AddStep("catch kiai fruit", () =>
|
AddStep("catch kiai fruit", () =>
|
||||||
{
|
{
|
||||||
drawableObject = createDrawableObject(new TestKiaiFruit());
|
attemptCatch(new TestKiaiFruit(), out drawableObject, out result);
|
||||||
result = attemptCatch(drawableObject);
|
|
||||||
});
|
});
|
||||||
checkState(CatcherAnimationState.Kiai);
|
checkState(CatcherAnimationState.Kiai);
|
||||||
AddStep("revert result", () =>
|
AddStep("revert result", () =>
|
||||||
@ -200,13 +198,22 @@ namespace osu.Game.Rulesets.Catch.Tests
|
|||||||
AddAssert("fruits are dropped", () => !catcher.CaughtObjects.Any() && droppedObjectContainer.Count == 10);
|
AddAssert("fruits are dropped", () => !catcher.CaughtObjects.Any() && droppedObjectContainer.Count == 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
[TestCase(true)]
|
[Test]
|
||||||
[TestCase(false)]
|
public void TestHitLightingColour()
|
||||||
public void TestHitLighting(bool enabled)
|
|
||||||
{
|
{
|
||||||
AddStep($"{(enabled ? "enable" : "disable")} hit lighting", () => config.Set(OsuSetting.HitLighting, enabled));
|
var fruitColour = SkinConfiguration.DefaultComboColours[1];
|
||||||
|
AddStep("enable hit lighting", () => config.Set(OsuSetting.HitLighting, true));
|
||||||
AddStep("catch fruit", () => attemptCatch(new Fruit()));
|
AddStep("catch fruit", () => attemptCatch(new Fruit()));
|
||||||
AddAssert("check hit lighting", () => catcher.ChildrenOfType<HitExplosion>().Any() == enabled);
|
AddAssert("correct hit lighting colour", () =>
|
||||||
|
catcher.ChildrenOfType<HitExplosion>().First()?.ObjectColour == fruitColour);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestHitLightingDisabled()
|
||||||
|
{
|
||||||
|
AddStep("disable hit lighting", () => config.Set(OsuSetting.HitLighting, false));
|
||||||
|
AddStep("catch fruit", () => attemptCatch(new Fruit()));
|
||||||
|
AddAssert("no hit lighting", () => !catcher.ChildrenOfType<HitExplosion>().Any());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkPlate(int count) => AddAssert($"{count} objects on the plate", () => catcher.CaughtObjects.Count() == count);
|
private void checkPlate(int count) => AddAssert($"{count} objects on the plate", () => catcher.CaughtObjects.Count() == count);
|
||||||
@ -218,18 +225,34 @@ namespace osu.Game.Rulesets.Catch.Tests
|
|||||||
private void attemptCatch(CatchHitObject hitObject, int count = 1)
|
private void attemptCatch(CatchHitObject hitObject, int count = 1)
|
||||||
{
|
{
|
||||||
for (var i = 0; i < count; i++)
|
for (var i = 0; i < count; i++)
|
||||||
attemptCatch(createDrawableObject(hitObject));
|
attemptCatch(hitObject, out _, out _);
|
||||||
}
|
}
|
||||||
|
|
||||||
private JudgementResult attemptCatch(DrawableCatchHitObject drawableObject)
|
private void attemptCatch(CatchHitObject hitObject, out DrawableCatchHitObject drawableObject, out JudgementResult result)
|
||||||
{
|
{
|
||||||
drawableObject.HitObject.ApplyDefaults(new ControlPointInfo(), new BeatmapDifficulty());
|
hitObject.ApplyDefaults(new ControlPointInfo(), new BeatmapDifficulty());
|
||||||
var result = new CatchJudgementResult(drawableObject.HitObject, drawableObject.HitObject.CreateJudgement())
|
drawableObject = createDrawableObject(hitObject);
|
||||||
|
result = createResult(hitObject);
|
||||||
|
applyResult(drawableObject, result);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void applyResult(DrawableCatchHitObject drawableObject, JudgementResult result)
|
||||||
|
{
|
||||||
|
// Load DHO to set colour of hit explosion correctly
|
||||||
|
Add(drawableObject);
|
||||||
|
drawableObject.OnLoadComplete += _ =>
|
||||||
{
|
{
|
||||||
Type = catcher.CanCatch(drawableObject.HitObject) ? HitResult.Great : HitResult.Miss
|
catcher.OnNewResult(drawableObject, result);
|
||||||
|
drawableObject.Expire();
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
private JudgementResult createResult(CatchHitObject hitObject)
|
||||||
|
{
|
||||||
|
return new CatchJudgementResult(hitObject, hitObject.CreateJudgement())
|
||||||
|
{
|
||||||
|
Type = catcher.CanCatch(hitObject) ? HitResult.Great : HitResult.Miss
|
||||||
};
|
};
|
||||||
catcher.OnNewResult(drawableObject, result);
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private DrawableCatchHitObject createDrawableObject(CatchHitObject hitObject)
|
private DrawableCatchHitObject createDrawableObject(CatchHitObject hitObject)
|
||||||
|
Loading…
Reference in New Issue
Block a user