1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-18 08:42:56 +08:00
osu-lazer/osu.Game.Tests/Visual/Gameplay/TestSceneStarCounter.cs
2022-11-27 00:00:27 +09:00

56 lines
1.5 KiB
C#

// 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.
#nullable disable
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 partial class TestSceneStarCounter : OsuTestScene
{
private readonly StarCounter starCounter;
private readonly OsuSpriteText starsLabel;
public TestSceneStarCounter()
{
starCounter = new StarCounter
{
Origin = Anchor.Centre,
Anchor = Anchor.Centre,
};
Add(starCounter);
starsLabel = new OsuSpriteText
{
Origin = Anchor.Centre,
Anchor = Anchor.Centre,
Scale = new Vector2(2),
Y = 50,
};
Add(starsLabel);
setStars(5);
AddRepeatStep("random value", () => setStars(RNG.NextSingle() * (starCounter.StarCount + 1)), 10);
AddSliderStep("exact value", 0f, 10f, 5f, setStars);
AddStep("stop animation", () => starCounter.StopAnimation());
AddStep("reset", () => setStars(0));
}
private void setStars(float stars)
{
starCounter.Current = stars;
starsLabel.Text = starCounter.Current.ToString("0.00");
}
}
}