1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-08 06:19:38 +08:00
osu-lazer/osu.Game/Screens/Play/HUD/DefaultComboCounter.cs

61 lines
1.8 KiB
C#
Raw Normal View History

// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
2018-04-13 17:19:50 +08:00
using System;
2018-11-16 04:37:21 +08:00
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Game.Graphics;
using osu.Game.Graphics.Sprites;
using osu.Game.Graphics.UserInterface;
using osuTK;
2018-04-13 17:19:50 +08:00
namespace osu.Game.Screens.Play.HUD
2018-04-13 17:19:50 +08:00
{
public class DefaultComboCounter : RollingCounter<int>, IComboCounter
2018-04-13 17:19:50 +08:00
{
private readonly Vector2 offset = new Vector2(20, 5);
2018-04-13 17:19:50 +08:00
protected override double RollingDuration => 750;
[Resolved(canBeNull: true)]
private HUDOverlay hud { get; set; }
public DefaultComboCounter()
2018-04-13 17:19:50 +08:00
{
Current.Value = DisplayedCount = 0;
Anchor = Anchor.TopCentre;
Origin = Anchor.TopLeft;
Position = offset;
2018-04-13 17:19:50 +08:00
}
2018-11-16 04:37:21 +08:00
[BackgroundDependencyLoader]
private void load(OsuColour colours) => Colour = colours.BlueLighter;
2018-11-16 04:37:21 +08:00
protected override void Update()
{
base.Update();
if (hud != null)
{
// for now align with the score counter. eventually this will be user customisable.
Position += ToLocalSpace(hud.ScoreCounter.ScreenSpaceDrawQuad.TopRight) + offset;
}
}
2018-04-13 17:19:50 +08:00
protected override string FormatCount(int count)
{
return $@"{count}x";
}
protected override double GetProportionalDuration(int currentValue, int newValue)
{
return Math.Abs(currentValue - newValue) * RollingDuration * 100.0f;
}
protected override OsuSpriteText CreateSpriteText()
=> base.CreateSpriteText().With(s => s.Font = s.Font.With(size: 20f));
2018-04-13 17:19:50 +08:00
}
}