1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-18 12:32:54 +08:00
osu-lazer/osu.Game.Modes.Taiko/UI/TaikoComboCounter.cs

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