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

176 lines
5.6 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
using System;
2017-02-17 17:59:30 +08:00
using osu.Framework.Screens.Testing;
2016-10-07 15:05:02 +08:00
using osu.Framework.Graphics;
using osu.Framework.Graphics.Sprites;
using osu.Framework.MathUtils;
using osu.Game.Graphics.UserInterface;
2016-11-14 17:54:24 +08:00
using osu.Game.Modes.Catch.UI;
using osu.Game.Modes.Mania.UI;
using osu.Game.Modes.Osu.UI;
using osu.Game.Modes.Taiko.UI;
using osu.Game.Modes.UI;
using OpenTK;
using OpenTK.Graphics;
using osu.Framework.Graphics.Primitives;
2016-10-07 15:05:02 +08:00
namespace osu.Desktop.VisualTests.Tests
2016-10-07 15:05:02 +08:00
{
class TestCaseScoreCounter : TestCase
{
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;
bool maniaHold = false;
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,
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
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,
Margin = new MarginPadding(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);
ManiaComboCounter maniaCombo = new ManiaComboCounter
2016-10-15 07:23:27 +08:00
{
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-07 15:05:02 +08:00
};
2016-10-13 09:58:43 +08:00
Add(accuracyCombo);
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);
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-16 08:07:07 +08:00
taikoCombo.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(@"mania hold", delegate
{
if (!maniaHold)
maniaCombo.HoldStart();
else
maniaCombo.HoldEnd();
maniaHold = !maniaHold;
});
AddButton(@"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");
});
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
}
}
}