2020-12-02 15:55:58 +08:00
|
|
|
// 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.
|
|
|
|
|
2022-06-17 15:37:17 +08:00
|
|
|
#nullable disable
|
|
|
|
|
2020-12-02 15:55:58 +08:00
|
|
|
using NUnit.Framework;
|
|
|
|
using osu.Game.Rulesets.Catch.Objects;
|
|
|
|
using osu.Game.Rulesets.Catch.Objects.Drawables;
|
|
|
|
using osu.Game.Tests.Visual;
|
2020-12-10 19:43:01 +08:00
|
|
|
using osuTK;
|
2020-12-02 16:16:36 +08:00
|
|
|
using osuTK.Graphics;
|
2020-12-02 15:55:58 +08:00
|
|
|
|
|
|
|
namespace osu.Game.Rulesets.Catch.Tests
|
|
|
|
{
|
2022-11-24 13:32:20 +08:00
|
|
|
public partial class TestSceneFruitRandomness : OsuTestScene
|
2020-12-02 15:55:58 +08:00
|
|
|
{
|
2020-12-08 19:05:18 +08:00
|
|
|
private readonly DrawableFruit drawableFruit;
|
|
|
|
private readonly DrawableBanana drawableBanana;
|
2020-12-02 15:55:58 +08:00
|
|
|
|
2020-12-02 17:06:14 +08:00
|
|
|
public TestSceneFruitRandomness()
|
|
|
|
{
|
2020-12-08 19:05:18 +08:00
|
|
|
drawableFruit = new DrawableFruit(new Fruit());
|
|
|
|
drawableBanana = new DrawableBanana(new Banana());
|
2020-12-02 15:55:58 +08:00
|
|
|
|
2020-12-02 16:20:52 +08:00
|
|
|
Add(new TestDrawableCatchHitObjectSpecimen(drawableFruit) { X = -200 });
|
|
|
|
Add(new TestDrawableCatchHitObjectSpecimen(drawableBanana));
|
2020-12-02 15:55:58 +08:00
|
|
|
|
2020-12-02 19:53:47 +08:00
|
|
|
AddSliderStep("start time", 500, 600, 0, x =>
|
|
|
|
{
|
|
|
|
drawableFruit.HitObject.StartTime = drawableBanana.HitObject.StartTime = x;
|
|
|
|
});
|
2020-12-02 17:06:14 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void TestFruitRandomness()
|
|
|
|
{
|
2020-12-02 19:53:47 +08:00
|
|
|
// Use values such that the banana colour changes (2/3 of the integers are okay)
|
|
|
|
const int initial_start_time = 500;
|
|
|
|
const int another_start_time = 501;
|
|
|
|
|
2020-12-02 15:55:58 +08:00
|
|
|
float fruitRotation = 0;
|
|
|
|
float bananaRotation = 0;
|
2020-12-10 19:43:01 +08:00
|
|
|
Vector2 bananaSize = new Vector2();
|
2020-12-02 16:16:36 +08:00
|
|
|
Color4 bananaColour = new Color4();
|
2020-12-02 15:55:58 +08:00
|
|
|
|
2020-12-02 19:53:47 +08:00
|
|
|
AddStep("Initialize start time", () =>
|
2020-12-02 15:55:58 +08:00
|
|
|
{
|
2020-12-02 19:53:47 +08:00
|
|
|
drawableFruit.HitObject.StartTime = drawableBanana.HitObject.StartTime = initial_start_time;
|
2020-12-02 15:55:58 +08:00
|
|
|
|
2020-12-10 19:43:01 +08:00
|
|
|
fruitRotation = drawableFruit.DisplayRotation;
|
|
|
|
bananaRotation = drawableBanana.DisplayRotation;
|
|
|
|
bananaSize = drawableBanana.DisplaySize;
|
2020-12-02 16:16:36 +08:00
|
|
|
bananaColour = drawableBanana.AccentColour.Value;
|
2020-12-02 15:55:58 +08:00
|
|
|
});
|
|
|
|
|
2020-12-02 19:53:47 +08:00
|
|
|
AddStep("change start time", () =>
|
2020-12-02 15:55:58 +08:00
|
|
|
{
|
2020-12-02 19:53:47 +08:00
|
|
|
drawableFruit.HitObject.StartTime = drawableBanana.HitObject.StartTime = another_start_time;
|
2020-12-02 15:55:58 +08:00
|
|
|
});
|
|
|
|
|
2020-12-10 19:43:01 +08:00
|
|
|
AddAssert("fruit rotation is changed", () => drawableFruit.DisplayRotation != fruitRotation);
|
|
|
|
AddAssert("banana rotation is changed", () => drawableBanana.DisplayRotation != bananaRotation);
|
|
|
|
AddAssert("banana size is changed", () => drawableBanana.DisplaySize != bananaSize);
|
2020-12-02 16:16:36 +08:00
|
|
|
AddAssert("banana colour is changed", () => drawableBanana.AccentColour.Value != bananaColour);
|
2020-12-02 15:55:58 +08:00
|
|
|
|
2020-12-02 19:53:47 +08:00
|
|
|
AddStep("reset start time", () =>
|
2020-12-02 15:55:58 +08:00
|
|
|
{
|
2020-12-02 19:53:47 +08:00
|
|
|
drawableFruit.HitObject.StartTime = drawableBanana.HitObject.StartTime = initial_start_time;
|
2020-12-02 15:55:58 +08:00
|
|
|
});
|
|
|
|
|
2020-12-10 19:43:01 +08:00
|
|
|
AddAssert("rotation and size restored", () =>
|
|
|
|
drawableFruit.DisplayRotation == fruitRotation &&
|
|
|
|
drawableBanana.DisplayRotation == bananaRotation &&
|
|
|
|
drawableBanana.DisplaySize == bananaSize &&
|
2020-12-02 16:16:36 +08:00
|
|
|
drawableBanana.AccentColour.Value == bananaColour);
|
2020-12-02 15:55:58 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|