1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-08 06:10:05 +08:00
osu-lazer/osu.Desktop.VisualTests/Tests/TestCaseScoreCounter.cs

168 lines
5.4 KiB
C#
Raw Normal View History

2016-10-07 15:05:02 +08:00
//Copyright (c) 2007-2016 ppy Pty Ltd <contact@ppy.sh>.
//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System;
using OpenTK.Input;
using osu.Framework.GameModes.Testing;
using osu.Framework.Graphics;
using osu.Game.Graphics.UserInterface;
using osu.Framework.Graphics.UserInterface;
using osu.Framework.Graphics.Transformations;
using OpenTK;
using OpenTK.Graphics;
using osu.Framework.MathUtils;
using osu.Framework.Graphics.Sprites;
2016-10-15 07:23:27 +08:00
using osu.Game.GameModes.Play.Catch;
using osu.Game.GameModes.Play.Mania;
using osu.Game.GameModes.Play.Osu;
using osu.Game.GameModes.Play.Taiko;
2016-10-16 04:16:02 +08:00
using osu.Game.GameModes.Play;
2016-10-07 15:05:02 +08:00
namespace osu.Desktop.Tests
{
class TestCaseScoreCounter : TestCase
{
public override string Name => @"ScoreCounter";
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,
Count = 0,
Position = new Vector2(20, 20),
};
2016-10-13 09:58:43 +08:00
Add(score);
2016-10-07 15:05:02 +08:00
2016-10-15 07:23:27 +08:00
ComboCounter standardCombo = new OsuComboCounter
2016-10-07 15:05:02 +08:00
{
Origin = Anchor.BottomLeft,
Anchor = Anchor.BottomLeft,
2016-10-13 06:24:06 +08:00
Position = new Vector2(10, 10),
2016-10-13 04:28:24 +08:00
InnerCountPosition = new Vector2(10, 10),
2016-10-07 15:05:02 +08:00
Count = 0,
TextSize = 40,
};
2016-10-13 09:58:43 +08:00
Add(standardCombo);
2016-10-07 15:05:02 +08:00
2016-10-13 09:58:43 +08:00
CatchComboCounter catchCombo = new CatchComboCounter
2016-10-07 15:05:02 +08:00
{
Origin = Anchor.Centre,
Anchor = Anchor.Centre,
Count = 0,
TextSize = 40,
};
2016-10-13 09:58:43 +08:00
Add(catchCombo);
2016-10-07 15:05:02 +08:00
2016-10-15 07:23:27 +08:00
ComboCounter taikoCombo = new TaikoComboCounter
2016-10-07 15:05:02 +08:00
{
2016-10-15 07:23:27 +08:00
Origin = Anchor.BottomCentre,
Anchor = Anchor.Centre,
Position = new Vector2(0, -160),
Count = 0,
TextSize = 40,
};
Add(taikoCombo);
ComboCounter maniaCombo = new ManiaComboCounter
{
Origin = Anchor.Centre,
Anchor = Anchor.Centre,
Position = new Vector2(0, -80),
2016-10-07 15:05:02 +08:00
Count = 0,
TextSize = 40,
};
2016-10-15 07:23:27 +08:00
Add(maniaCombo);
2016-10-07 15:05:02 +08:00
2016-10-15 07:23:27 +08:00
PercentageCounter accuracyCombo = new PercentageCounter
2016-10-07 15:05:02 +08:00
{
Origin = Anchor.TopRight,
Anchor = Anchor.TopRight,
Position = new Vector2(20, 60),
};
2016-10-13 09:58:43 +08:00
Add(accuracyCombo);
2016-10-07 15:05:02 +08:00
2016-10-13 09:58:43 +08:00
SpriteText starsLabel = new SpriteText
{
Origin = Anchor.BottomLeft,
Anchor = Anchor.BottomLeft,
Position = new Vector2(20, 190),
Text = @"- unset -",
};
2016-10-13 09:58:43 +08:00
Add(starsLabel);
2016-10-13 09:58:43 +08:00
StarCounter stars = new StarCounter
{
Origin = Anchor.BottomLeft,
Anchor = Anchor.BottomLeft,
Position = new Vector2(20, 160),
};
2016-10-13 09:58:43 +08:00
Add(stars);
2016-10-08 06:15:36 +08:00
AddButton(@"Reset all", delegate
2016-10-07 15:05:02 +08:00
{
2016-10-13 09:58:43 +08:00
score.Count = 0;
standardCombo.Count = 0;
2016-10-15 07:23:27 +08:00
maniaCombo.Count = 0;
2016-10-13 09:58:43 +08:00
catchCombo.Count = 0;
2016-10-15 07:23:27 +08:00
numerator = denominator = 0;
accuracyCombo.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
2016-10-08 06:15:36 +08:00
AddButton(@"Hit! :D", delegate
2016-10-07 15:05:02 +08:00
{
2016-10-13 09:58:43 +08:00
score.Count += 300 + (ulong)(300.0 * (standardCombo.Count > 0 ? standardCombo.Count - 1 : 0) / 25.0);
standardCombo.Count++;
2016-10-15 07:23:27 +08:00
taikoCombo.Count++;
maniaCombo.Count++;
2016-10-13 09:58:43 +08:00
catchCombo.CatchFruit(new Color4(
2016-10-07 15:05:02 +08:00
Math.Max(0.5f, RNG.NextSingle()),
Math.Max(0.5f, RNG.NextSingle()),
Math.Max(0.5f, RNG.NextSingle()),
1)
);
2016-10-15 07:23:27 +08:00
numerator++; denominator++;
accuracyCombo.SetFraction(numerator, denominator);
2016-10-08 06:15:36 +08:00
});
2016-10-07 15:05:02 +08:00
2016-10-08 06:15:36 +08:00
AddButton(@"miss...", delegate
2016-10-07 15:05:02 +08:00
{
2016-10-14 08:50:06 +08:00
standardCombo.Roll();
2016-10-15 07:23:27 +08:00
taikoCombo.Roll();
maniaCombo.Roll();
2016-10-14 08:50:06 +08:00
catchCombo.Roll();
2016-10-15 07:23:27 +08:00
denominator++;
accuracyCombo.SetFraction(numerator, denominator);
2016-10-08 06:15:36 +08:00
});
2016-10-07 15:05:02 +08:00
AddButton(@"Alter stars", delegate
{
2016-10-13 09:58:43 +08:00
stars.Count = RNG.NextSingle() * (stars.MaxStars + 1);
starsLabel.Text = stars.Count.ToString("0.00");
});
2016-10-08 06:15:36 +08:00
AddButton(@"Stop counters", delegate
2016-10-07 15:05:02 +08:00
{
2016-10-13 09:58:43 +08:00
score.StopRolling();
standardCombo.StopRolling();
catchCombo.StopRolling();
2016-10-15 07:23:27 +08:00
taikoCombo.StopRolling();
maniaCombo.StopRolling();
2016-10-13 09:58:43 +08:00
accuracyCombo.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
}
}
}