// Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using System; using osu.Framework.Graphics; using osu.Framework.Graphics.Transforms; using osu.Framework.MathUtils; using osu.Game.Graphics.UserInterface; namespace osu.Game.Screens.Play.HUD { /// /// Used to display combo with a roll-up animation in results screen. /// public class ComboResultCounter : RollingCounter { protected override Type TransformType => typeof(TransformComboResult); protected override double RollingDuration => 500; protected override EasingTypes RollingEasing => EasingTypes.Out; protected override double GetProportionalDuration(ulong currentValue, ulong newValue) { return currentValue > newValue ? currentValue - newValue : newValue - currentValue; } protected override string FormatCount(ulong count) { return $@"{count}x"; } public override void Increment(ulong amount) { Current.Value = Current + amount; } protected class TransformComboResult : Transform { public override ulong CurrentValue { get { double time = Time?.Current ?? 0; if (time < StartTime) return StartValue; if (time >= EndTime) return EndValue; return (ulong)Interpolation.ValueAt(time, StartValue, EndValue, StartTime, EndTime, Easing); } } public override void Apply(Drawable d) { base.Apply(d); ((ComboResultCounter)d).DisplayedCount = CurrentValue; } } } }