1
0
mirror of https://github.com/ppy/osu.git synced 2025-02-15 06:13:03 +08:00
osu-lazer/osu.Game/Graphics/UserInterface/AlternativeComboCounter.cs

68 lines
2.2 KiB
C#
Raw Normal View History

2016-10-07 15:24:46 +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 OpenTK;
2016-10-07 15:05:02 +08:00
using OpenTK.Graphics;
using osu.Framework;
2016-10-07 15:05:02 +08:00
using osu.Framework.Graphics.Transformations;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace osu.Game.Graphics.UserInterface
{
/// <summary>
2016-10-08 05:14:35 +08:00
/// Allows tint and vertical scaling animation. Used in osu!taiko and osu!mania.
2016-10-07 15:05:02 +08:00
/// </summary>
2016-10-14 06:13:20 +08:00
public class AlternativeComboCounter : ComboCounter
2016-10-07 15:05:02 +08:00
{
public Color4 OriginalColour;
public Color4 TintColour = Color4.OrangeRed;
public int TintDuration = 250;
2016-10-08 05:14:35 +08:00
public float ScaleFactor = 2;
2016-10-07 15:05:02 +08:00
public EasingTypes TintEasing = EasingTypes.None;
public bool CanAnimateWhenBackwards = false;
public override void Load(BaseGame game)
2016-10-07 15:05:02 +08:00
{
base.Load(game);
2016-10-07 15:05:02 +08:00
OriginalColour = Colour;
}
public override void ResetCount()
{
SetCountWithoutRolling(0);
}
protected override ulong getProportionalDuration(ulong currentValue, ulong newValue)
2016-10-07 15:05:02 +08:00
{
ulong difference = currentValue > newValue ? currentValue - newValue : currentValue - newValue;
return difference * RollingDuration;
}
2016-10-13 06:24:06 +08:00
protected virtual void transformAnimate(ulong newValue)
2016-10-07 15:05:02 +08:00
{
2016-10-10 04:19:35 +08:00
countSpriteText.FadeColour(TintColour, 0);
2016-10-07 15:05:02 +08:00
countSpriteText.ScaleTo(new Vector2(1, ScaleFactor));
countSpriteText.FadeColour(OriginalColour, TintDuration, TintEasing);
countSpriteText.ScaleTo(new Vector2(1, 1), TintDuration, TintEasing);
}
protected override void transformVisibleCount(ulong currentValue, ulong newValue)
{
2016-10-13 06:24:06 +08:00
countSpriteText.Text = formatCount(newValue);
if (newValue == 0)
countSpriteText.FadeOut(TintDuration);
else
2016-10-07 15:05:02 +08:00
countSpriteText.Show();
2016-10-13 06:24:06 +08:00
if (newValue > currentValue || CanAnimateWhenBackwards)
transformAnimate(newValue);
2016-10-07 15:05:02 +08:00
}
}
}