2020-03-09 00:26:19 +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-03-09 00:26:19 +08:00
|
|
|
using NUnit.Framework;
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
using osu.Framework.Utils;
|
|
|
|
using osu.Game.Graphics.Sprites;
|
|
|
|
using osu.Game.Graphics.UserInterface;
|
|
|
|
using osuTK;
|
|
|
|
|
|
|
|
namespace osu.Game.Tests.Visual.Gameplay
|
|
|
|
{
|
|
|
|
[TestFixture]
|
|
|
|
public class TestSceneStarCounter : OsuTestScene
|
|
|
|
{
|
2020-11-29 03:29:35 +08:00
|
|
|
private readonly StarCounter starCounter;
|
|
|
|
private readonly OsuSpriteText starsLabel;
|
|
|
|
|
2020-03-09 00:26:19 +08:00
|
|
|
public TestSceneStarCounter()
|
|
|
|
{
|
2020-11-29 03:29:35 +08:00
|
|
|
starCounter = new StarCounter
|
2020-03-09 00:26:19 +08:00
|
|
|
{
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
};
|
|
|
|
|
2020-11-29 03:29:35 +08:00
|
|
|
Add(starCounter);
|
2020-03-09 00:26:19 +08:00
|
|
|
|
2020-11-29 03:29:35 +08:00
|
|
|
starsLabel = new OsuSpriteText
|
2020-03-09 00:26:19 +08:00
|
|
|
{
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
Scale = new Vector2(2),
|
|
|
|
Y = 50,
|
|
|
|
};
|
|
|
|
|
|
|
|
Add(starsLabel);
|
|
|
|
|
2020-11-29 03:29:35 +08:00
|
|
|
setStars(5);
|
2020-03-09 00:26:19 +08:00
|
|
|
|
2020-11-29 03:29:35 +08:00
|
|
|
AddRepeatStep("random value", () => setStars(RNG.NextSingle() * (starCounter.StarCount + 1)), 10);
|
2020-11-29 03:32:08 +08:00
|
|
|
AddSliderStep("exact value", 0f, 10f, 5f, setStars);
|
2020-11-29 03:29:35 +08:00
|
|
|
AddStep("stop animation", () => starCounter.StopAnimation());
|
|
|
|
AddStep("reset", () => setStars(0));
|
|
|
|
}
|
2020-03-09 00:26:19 +08:00
|
|
|
|
2020-11-29 03:29:35 +08:00
|
|
|
private void setStars(float stars)
|
|
|
|
{
|
|
|
|
starCounter.Current = stars;
|
|
|
|
starsLabel.Text = starCounter.Current.ToString("0.00");
|
2020-03-09 00:26:19 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|