1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-16 02:22:59 +08:00
osu-lazer/osu.Game.Tests/Visual/Gameplay/TestSceneStarCounter.cs

54 lines
1.5 KiB
C#
Raw Normal View History

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.
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);
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
}
}
}