1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 10:12:54 +08:00

Rewrite existing test scene somewhat

This commit is contained in:
Bartłomiej Dach 2020-11-28 20:29:35 +01:00
parent 8ad4cf73f5
commit 8e0f525588

View File

@ -3,7 +3,6 @@
using NUnit.Framework; using NUnit.Framework;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Utils; using osu.Framework.Utils;
using osu.Game.Graphics.Sprites; using osu.Game.Graphics.Sprites;
using osu.Game.Graphics.UserInterface; using osu.Game.Graphics.UserInterface;
@ -14,44 +13,40 @@ namespace osu.Game.Tests.Visual.Gameplay
[TestFixture] [TestFixture]
public class TestSceneStarCounter : OsuTestScene public class TestSceneStarCounter : OsuTestScene
{ {
private readonly StarCounter starCounter;
private readonly OsuSpriteText starsLabel;
public TestSceneStarCounter() public TestSceneStarCounter()
{ {
StarCounter stars = new StarCounter starCounter = new StarCounter
{ {
Origin = Anchor.Centre, Origin = Anchor.Centre,
Anchor = Anchor.Centre, Anchor = Anchor.Centre,
Current = 5,
}; };
Add(stars); Add(starCounter);
SpriteText starsLabel = new OsuSpriteText starsLabel = new OsuSpriteText
{ {
Origin = Anchor.Centre, Origin = Anchor.Centre,
Anchor = Anchor.Centre, Anchor = Anchor.Centre,
Scale = new Vector2(2), Scale = new Vector2(2),
Y = 50, Y = 50,
Text = stars.Current.ToString("0.00"),
}; };
Add(starsLabel); Add(starsLabel);
AddRepeatStep(@"random value", delegate setStars(5);
{
stars.Current = RNG.NextSingle() * (stars.StarCount + 1);
starsLabel.Text = stars.Current.ToString("0.00");
}, 10);
AddStep(@"Stop animation", delegate AddRepeatStep("random value", () => setStars(RNG.NextSingle() * (starCounter.StarCount + 1)), 10);
{ AddStep("stop animation", () => starCounter.StopAnimation());
stars.StopAnimation(); AddStep("reset", () => setStars(0));
}); }
AddStep(@"Reset", delegate private void setStars(float stars)
{ {
stars.Current = 0; starCounter.Current = stars;
starsLabel.Text = stars.Current.ToString("0.00"); starsLabel.Text = starCounter.Current.ToString("0.00");
});
} }
} }
} }