osu/osu.Desktop.VisualTests/Tests/TestCaseScoreCounter.cs

184 lines
5.8 KiB
C#
Raw Normal View History

2016-10-07 07:05:02 +00: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 osu.Framework.GameModes.Testing;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Sprites;
using osu.Framework.MathUtils;
using osu.Game.Graphics.UserInterface;
2016-11-14 09:03:20 +00:00
using osu.Game.Modes;
using osu.Game.Modes.Catch;
2016-11-14 09:54:24 +00:00
using osu.Game.Modes.Catch.UI;
2016-11-14 09:03:20 +00:00
using osu.Game.Modes.Mania;
2016-11-14 09:54:24 +00:00
using osu.Game.Modes.Mania.UI;
2016-11-14 09:03:20 +00:00
using osu.Game.Modes.Osu;
2016-11-14 09:54:24 +00:00
using osu.Game.Modes.Osu.UI;
2016-11-14 09:03:20 +00:00
using osu.Game.Modes.Taiko;
2016-11-14 09:54:24 +00:00
using osu.Game.Modes.Taiko.UI;
using osu.Game.Modes.UI;
2016-11-14 08:23:33 +00:00
using osu.Game.Screens.Play;
using OpenTK;
using OpenTK.Graphics;
using osu.Framework.Graphics.Primitives;
2016-10-07 07:05:02 +00:00
namespace osu.Desktop.VisualTests.Tests
2016-10-07 07:05:02 +00:00
{
class TestCaseScoreCounter : TestCase
{
public override string Name => @"ScoreCounter";
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;
bool maniaHold = false;
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,
Count = 0,
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
2016-10-14 23:23:27 +00:00
ComboCounter standardCombo = new OsuComboCounter
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
Count = 0,
TextSize = 40,
};
2016-10-13 01:58:43 +00:00
Add(standardCombo);
2016-10-07 07:05:02 +00:00
2016-10-13 01:58:43 +00:00
CatchComboCounter catchCombo = new CatchComboCounter
2016-10-07 07:05:02 +00:00
{
Origin = Anchor.Centre,
Anchor = Anchor.Centre,
Count = 0,
TextSize = 40,
};
2016-10-13 01:58:43 +00:00
Add(catchCombo);
2016-10-07 07:05:02 +00:00
2016-10-14 23:23:27 +00:00
ComboCounter taikoCombo = new TaikoComboCounter
2016-10-07 07:05:02 +00:00
{
2016-10-14 23:23:27 +00:00
Origin = Anchor.BottomCentre,
Anchor = Anchor.Centre,
Position = new Vector2(0, -160),
Count = 0,
TextSize = 40,
};
Add(taikoCombo);
ManiaComboCounter maniaCombo = new ManiaComboCounter
2016-10-14 23:23:27 +00:00
{
Origin = Anchor.Centre,
Anchor = Anchor.Centre,
Position = new Vector2(0, -80),
2016-10-07 07:05:02 +00:00
Count = 0,
TextSize = 40,
};
2016-10-14 23:23:27 +00:00
Add(maniaCombo);
2016-10-07 07:05:02 +00:00
2016-10-14 23:23:27 +00:00
PercentageCounter accuracyCombo = 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
};
2016-10-13 01:58:43 +00:00
Add(accuracyCombo);
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);
2016-10-07 22:15:36 +00:00
AddButton(@"Reset all", delegate
2016-10-07 07:05:02 +00:00
{
2016-10-13 01:58:43 +00:00
score.Count = 0;
standardCombo.Count = 0;
2016-10-16 00:07:07 +00:00
taikoCombo.Count = 0;
2016-10-14 23:23:27 +00:00
maniaCombo.Count = 0;
2016-10-13 01:58:43 +00:00
catchCombo.Count = 0;
2016-10-14 23:23:27 +00:00
numerator = denominator = 0;
accuracyCombo.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
2016-10-07 22:15:36 +00:00
AddButton(@"Hit! :D", delegate
2016-10-07 07:05:02 +00:00
{
2016-10-13 01:58:43 +00:00
score.Count += 300 + (ulong)(300.0 * (standardCombo.Count > 0 ? standardCombo.Count - 1 : 0) / 25.0);
standardCombo.Count++;
2016-10-14 23:23:27 +00:00
taikoCombo.Count++;
maniaCombo.Count++;
2016-10-13 01:58:43 +00:00
catchCombo.CatchFruit(new Color4(
2016-10-07 07:05:02 +00:00
Math.Max(0.5f, RNG.NextSingle()),
Math.Max(0.5f, RNG.NextSingle()),
Math.Max(0.5f, RNG.NextSingle()),
1)
);
2016-10-14 23:23:27 +00:00
numerator++; denominator++;
accuracyCombo.SetFraction(numerator, denominator);
2016-10-07 22:15:36 +00:00
});
2016-10-07 07:05:02 +00:00
2016-10-07 22:15:36 +00:00
AddButton(@"miss...", delegate
2016-10-07 07:05:02 +00:00
{
2016-10-14 00:50:06 +00:00
standardCombo.Roll();
2016-10-14 23:23:27 +00:00
taikoCombo.Roll();
maniaCombo.Roll();
2016-10-14 00:50:06 +00:00
catchCombo.Roll();
2016-10-14 23:23:27 +00:00
denominator++;
accuracyCombo.SetFraction(numerator, denominator);
2016-10-07 22:15:36 +00:00
});
2016-10-07 07:05:02 +00:00
AddButton(@"mania hold", delegate
{
if (!maniaHold)
maniaCombo.HoldStart();
else
maniaCombo.HoldEnd();
maniaHold = !maniaHold;
});
AddButton(@"Alter stars", delegate
{
2016-10-13 01:58:43 +00:00
stars.Count = RNG.NextSingle() * (stars.MaxStars + 1);
starsLabel.Text = stars.Count.ToString("0.00");
});
2016-10-07 22:15:36 +00:00
AddButton(@"Stop counters", delegate
2016-10-07 07:05:02 +00:00
{
2016-10-13 01:58:43 +00:00
score.StopRolling();
standardCombo.StopRolling();
catchCombo.StopRolling();
2016-10-14 23:23:27 +00:00
taikoCombo.StopRolling();
maniaCombo.StopRolling();
2016-10-13 01:58:43 +00:00
accuracyCombo.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
}
}
}