1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-14 21:17:33 +08:00
osu-lazer/osu.Desktop.VisualTests/Tests/TestCaseScoreCounter.cs

110 lines
3.5 KiB
C#
Raw Normal View History

// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
2016-10-07 15:05:02 +08:00
2017-03-10 10:04:46 +08:00
using OpenTK;
2016-10-07 15:05:02 +08:00
using osu.Framework.Graphics;
2017-03-10 10:04:46 +08:00
using osu.Framework.Graphics.Primitives;
using osu.Framework.Graphics.Sprites;
using osu.Framework.MathUtils;
2017-03-28 20:03:34 +08:00
using osu.Framework.Testing;
using osu.Game.Graphics.UserInterface;
2016-11-14 17:54:24 +08:00
using osu.Game.Modes.UI;
2016-10-07 15:05:02 +08:00
namespace osu.Desktop.VisualTests.Tests
2016-10-07 15:05:02 +08:00
{
2017-03-07 09:59:19 +08:00
internal class TestCaseScoreCounter : TestCase
2016-10-07 15:05:02 +08:00
{
public override string Description => @"Tests multiple counters";
public override void Reset()
{
base.Reset();
2016-10-15 07:23:27 +08:00
int numerator = 0, denominator = 0;
2016-10-13 09:58:43 +08:00
ScoreCounter score = new ScoreCounter(7)
2016-10-07 15:05:02 +08:00
{
Origin = Anchor.TopRight,
Anchor = Anchor.TopRight,
TextSize = 40,
Margin = new MarginPadding(20),
2016-10-07 15:05:02 +08:00
};
2016-10-13 09:58:43 +08:00
Add(score);
2016-10-07 15:05:02 +08:00
ComboCounter comboCounter = new StandardComboCounter
2016-10-07 15:05:02 +08:00
{
Origin = Anchor.BottomLeft,
Anchor = Anchor.BottomLeft,
Margin = new MarginPadding(10),
2016-10-07 15:05:02 +08:00
TextSize = 40,
};
Add(comboCounter);
2016-10-07 15:05:02 +08:00
PercentageCounter accuracyCounter = new PercentageCounter
2016-10-07 15:05:02 +08:00
{
Origin = Anchor.TopRight,
Anchor = Anchor.TopRight,
Position = new Vector2(-20, 60),
2016-10-07 15:05:02 +08:00
};
Add(accuracyCounter);
2016-10-07 15:05:02 +08:00
2016-10-17 07:30:25 +08:00
StarCounter stars = new StarCounter
{
Origin = Anchor.BottomLeft,
Anchor = Anchor.BottomLeft,
Position = new Vector2(20, -160),
2016-10-17 07:30:25 +08:00
Count = 5,
};
2016-10-17 07:30:25 +08:00
Add(stars);
2016-10-17 07:30:25 +08:00
SpriteText starsLabel = new SpriteText
{
Origin = Anchor.BottomLeft,
Anchor = Anchor.BottomLeft,
Position = new Vector2(20, -190),
2016-10-17 07:30:25 +08:00
Text = stars.Count.ToString("0.00"),
};
2016-10-17 07:30:25 +08:00
Add(starsLabel);
2017-03-31 16:55:07 +08:00
AddStep(@"Reset all", delegate
2016-10-07 15:05:02 +08:00
{
2017-03-10 12:08:59 +08:00
score.Current.Value = 0;
comboCounter.Current.Value = 0;
2016-10-15 07:23:27 +08:00
numerator = denominator = 0;
accuracyCounter.SetFraction(0, 0);
2016-10-13 09:58:43 +08:00
stars.Count = 0;
starsLabel.Text = stars.Count.ToString("0.00");
2016-10-08 06:15:36 +08:00
});
2016-10-07 15:05:02 +08:00
2017-03-31 16:55:07 +08:00
AddStep(@"Hit! :D", delegate
2016-10-07 15:05:02 +08:00
{
2017-03-10 13:44:38 +08:00
score.Current.Value += 300 + (ulong)(300.0 * (comboCounter.Current > 0 ? comboCounter.Current - 1 : 0) / 25.0);
comboCounter.Increment();
2016-10-15 07:23:27 +08:00
numerator++; denominator++;
accuracyCounter.SetFraction(numerator, denominator);
2016-10-08 06:15:36 +08:00
});
2016-10-07 15:05:02 +08:00
2017-03-31 16:55:07 +08:00
AddStep(@"miss...", delegate
2016-10-07 15:05:02 +08:00
{
comboCounter.Current.Value = 0;
2016-10-15 07:23:27 +08:00
denominator++;
accuracyCounter.SetFraction(numerator, denominator);
2016-10-08 06:15:36 +08:00
});
2016-10-07 15:05:02 +08:00
2017-03-31 16:55:07 +08:00
AddStep(@"Alter stars", delegate
{
stars.Count = RNG.NextSingle() * (stars.StarCount + 1);
2016-10-13 09:58:43 +08:00
starsLabel.Text = stars.Count.ToString("0.00");
});
2017-03-31 16:55:07 +08:00
AddStep(@"Stop counters", delegate
2016-10-07 15:05:02 +08:00
{
2016-10-13 09:58:43 +08:00
score.StopRolling();
comboCounter.StopRolling();
accuracyCounter.StopRolling();
2016-10-14 06:13:20 +08:00
stars.StopAnimation();
2016-10-08 06:15:36 +08:00
});
2016-10-07 15:05:02 +08:00
}
}
}