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