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

68 lines
2.3 KiB
C#
Raw Normal View History

2016-10-15 07:23:27 +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;
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
{
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
}
}
}