mirror of
https://github.com/ppy/osu.git
synced 2024-11-17 21:53:21 +08:00
68 lines
2.3 KiB
C#
68 lines
2.3 KiB
C#
//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;
|
|
using osu.Framework.Graphics.Transformations;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace osu.Game.GameModes.Play.Taiko
|
|
{
|
|
/// <summary>
|
|
/// Allows tint and scaling animations. Used in osu!taiko.
|
|
/// </summary>
|
|
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()
|
|
{
|
|
DisplayedCountSpriteText.Origin = Framework.Graphics.Anchor.BottomCentre;
|
|
DisplayedCountSpriteText.Anchor = Framework.Graphics.Anchor.BottomCentre;
|
|
}
|
|
|
|
protected virtual void TransformAnimate(ulong newValue)
|
|
{
|
|
DisplayedCountSpriteText.Text = FormatCount(newValue);
|
|
DisplayedCountSpriteText.ScaleTo(new Vector2(1, ScaleFactor));
|
|
DisplayedCountSpriteText.ScaleTo(new Vector2(1, 1), AnimationDuration, AnimationEasing);
|
|
}
|
|
|
|
protected virtual void TransformNotAnimate(ulong newValue)
|
|
{
|
|
DisplayedCountSpriteText.Text = FormatCount(newValue);
|
|
DisplayedCountSpriteText.ScaleTo(1);
|
|
}
|
|
|
|
protected override void OnDisplayedCountRolling(ulong currentValue, ulong newValue)
|
|
{
|
|
if (newValue == 0)
|
|
DisplayedCountSpriteText.FadeOut(AnimationDuration);
|
|
else
|
|
DisplayedCountSpriteText.Show();
|
|
|
|
TransformNotAnimate(newValue);
|
|
}
|
|
|
|
protected override void OnDisplayedCountChange(ulong newValue)
|
|
{
|
|
DisplayedCountSpriteText.FadeTo(newValue == 0 ? 0 : 1);
|
|
|
|
TransformNotAnimate(newValue);
|
|
}
|
|
|
|
protected override void OnDisplayedCountIncrement(ulong newValue)
|
|
{
|
|
DisplayedCountSpriteText.Show();
|
|
|
|
TransformAnimate(newValue);
|
|
}
|
|
}
|
|
}
|