osu/osu.Game.Modes.Taiko/UI/TaikoComboCounter.cs

64 lines
2.2 KiB
C#
Raw Normal View History

2016-10-14 23:23:27 +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 osu.Framework.Graphics.Transformations;
2016-11-14 09:54:24 +00:00
using osu.Game.Modes.UI;
2016-11-14 08:23:33 +00:00
using OpenTK;
2016-10-14 23:23:27 +00:00
2016-11-14 09:54:24 +00:00
namespace osu.Game.Modes.Taiko.UI
2016-10-14 23:23:27 +00:00
{
2016-10-15 20:03:51 +00:00
/// <summary>
/// Allows tint and scaling animations. Used in osu!taiko.
/// </summary>
2016-10-14 23:23:27 +00:00
public class TaikoComboCounter : ComboCounter
{
protected virtual int AnimationDuration => 300;
protected virtual float ScaleFactor => 2;
protected virtual EasingTypes AnimationEasing => EasingTypes.None;
protected virtual bool CanAnimateWhenBackwards => false;
public TaikoComboCounter()
{
2016-10-16 00:07:07 +00:00
DisplayedCountSpriteText.Origin = Framework.Graphics.Anchor.BottomCentre;
DisplayedCountSpriteText.Anchor = Framework.Graphics.Anchor.BottomCentre;
2016-10-14 23:23:27 +00:00
}
2016-10-16 23:30:25 +00:00
protected virtual void TransformAnimate(ulong newValue)
2016-10-14 23:23:27 +00:00
{
2016-10-16 00:07:07 +00:00
DisplayedCountSpriteText.Text = FormatCount(newValue);
DisplayedCountSpriteText.ScaleTo(new Vector2(1, ScaleFactor));
DisplayedCountSpriteText.ScaleTo(new Vector2(1, 1), AnimationDuration, AnimationEasing);
2016-10-14 23:23:27 +00:00
}
2016-10-16 23:30:25 +00:00
protected virtual void TransformNotAnimate(ulong newValue)
2016-10-14 23:23:27 +00:00
{
2016-10-16 00:07:07 +00:00
DisplayedCountSpriteText.Text = FormatCount(newValue);
DisplayedCountSpriteText.ScaleTo(1);
2016-10-14 23:23:27 +00:00
}
2016-10-16 00:07:07 +00:00
protected override void OnDisplayedCountRolling(ulong currentValue, ulong newValue)
2016-10-14 23:23:27 +00:00
{
if (newValue == 0)
2016-10-29 23:26:12 +00:00
DisplayedCountSpriteText.FadeOut(FadeOutDuration);
2016-10-14 23:23:27 +00:00
else
2016-10-16 00:07:07 +00:00
DisplayedCountSpriteText.Show();
2016-10-14 23:23:27 +00:00
2016-10-16 23:30:25 +00:00
TransformNotAnimate(newValue);
2016-10-14 23:23:27 +00:00
}
2016-10-16 00:07:07 +00:00
protected override void OnDisplayedCountChange(ulong newValue)
2016-10-14 23:23:27 +00:00
{
2016-10-16 00:07:07 +00:00
DisplayedCountSpriteText.FadeTo(newValue == 0 ? 0 : 1);
2016-10-14 23:23:27 +00:00
2016-10-16 23:30:25 +00:00
TransformNotAnimate(newValue);
2016-10-14 23:23:27 +00:00
}
2016-10-16 00:07:07 +00:00
protected override void OnDisplayedCountIncrement(ulong newValue)
2016-10-14 23:23:27 +00:00
{
2016-10-16 00:07:07 +00:00
DisplayedCountSpriteText.Show();
2016-10-14 23:23:27 +00:00
2016-10-16 23:30:25 +00:00
TransformAnimate(newValue);
2016-10-14 23:23:27 +00:00
}
}
}