1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-12 01:47:24 +08:00
osu-lazer/osu.Desktop.VisualTests/Tests/TestCaseScoreCounter.cs

160 lines
5.3 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-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-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,
RollingDuration = 1000,
RollingEasing = EasingTypes.Out,
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-13 09:58:43 +08:00
StandardComboCounter standardCombo = new StandardComboCounter
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
IsRollingProportional = true,
RollingDuration = 20,
2016-10-13 06:24:06 +08:00
PopOutDuration = 100,
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,
IsRollingProportional = true,
RollingDuration = 20,
2016-10-13 04:28:24 +08:00
PopOutDuration = 100,
2016-10-07 15:05:02 +08:00
Count = 0,
TextSize = 40,
};
2016-10-13 09:58:43 +08:00
Add(catchCombo);
2016-10-07 15:05:02 +08:00
2016-10-13 09:58:43 +08:00
AlternativeComboCounter alternativeCombo = new AlternativeComboCounter
2016-10-07 15:05:02 +08:00
{
Origin = Anchor.BottomLeft,
Anchor = Anchor.BottomLeft,
Position = new Vector2(20, 80),
IsRollingProportional = true,
RollingDuration = 20,
ScaleFactor = 2,
Count = 0,
TextSize = 40,
};
2016-10-13 09:58:43 +08:00
Add(alternativeCombo);
2016-10-07 15:05:02 +08:00
2016-10-13 09:58:43 +08:00
AccuracyCounter accuracyCombo = new AccuracyCounter
2016-10-07 15:05:02 +08:00
{
Origin = Anchor.TopRight,
Anchor = Anchor.TopRight,
2016-10-14 06:13:20 +08:00
RollingDuration = 500,
2016-10-07 15:05:02 +08:00
RollingEasing = EasingTypes.Out,
Count = 100.0f,
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;
alternativeCombo.Count = 0;
catchCombo.Count = 0;
accuracyCombo.SetCount(0, 0);
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++;
alternativeCombo.Count++;
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-13 09:58:43 +08:00
accuracyCombo.Numerator++;
accuracyCombo.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 06:13:20 +08:00
standardCombo.RollBack();
alternativeCombo.RollBack();
catchCombo.RollBack();
2016-10-13 09:58:43 +08:00
accuracyCombo.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();
alternativeCombo.StopRolling();
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
}
}
}