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