2017-02-07 12:59:30 +08:00
|
|
|
|
// 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-16 04:16:02 +08:00
|
|
|
|
|
|
|
|
|
using osu.Framework.Graphics;
|
2017-02-25 20:12:39 +08:00
|
|
|
|
using osu.Framework.Graphics.Transforms;
|
2016-10-16 04:16:02 +08:00
|
|
|
|
using osu.Framework.MathUtils;
|
|
|
|
|
using osu.Game.Graphics.UserInterface;
|
2017-03-10 12:08:59 +08:00
|
|
|
|
using System;
|
2016-10-16 04:16:02 +08:00
|
|
|
|
|
2017-04-18 15:05:58 +08:00
|
|
|
|
namespace osu.Game.Rulesets.UI
|
2016-10-16 04:16:02 +08:00
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Used to display combo with a roll-up animation in results screen.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public class ComboResultCounter : RollingCounter<ulong>
|
|
|
|
|
{
|
|
|
|
|
protected override Type TransformType => typeof(TransformComboResult);
|
|
|
|
|
|
2016-10-18 10:40:50 +08:00
|
|
|
|
protected override double RollingDuration => 500;
|
|
|
|
|
protected override EasingTypes RollingEasing => EasingTypes.Out;
|
2016-10-16 04:16:02 +08:00
|
|
|
|
|
|
|
|
|
protected override double GetProportionalDuration(ulong currentValue, ulong newValue)
|
|
|
|
|
{
|
|
|
|
|
return currentValue > newValue ? currentValue - newValue : newValue - currentValue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override string FormatCount(ulong count)
|
|
|
|
|
{
|
|
|
|
|
return $@"{count}x";
|
|
|
|
|
}
|
|
|
|
|
|
2016-10-19 18:44:03 +08:00
|
|
|
|
public override void Increment(ulong amount)
|
|
|
|
|
{
|
2017-03-10 12:08:59 +08:00
|
|
|
|
Current.Value = Current + amount;
|
2016-10-19 18:44:03 +08:00
|
|
|
|
}
|
|
|
|
|
|
2016-10-16 04:16:02 +08:00
|
|
|
|
protected class TransformComboResult : Transform<ulong>
|
|
|
|
|
{
|
2017-03-31 11:58:54 +08:00
|
|
|
|
public override ulong CurrentValue
|
2016-10-16 04:16:02 +08:00
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
2016-11-06 15:25:21 +08:00
|
|
|
|
double time = Time?.Current ?? 0;
|
2016-10-16 04:16:02 +08:00
|
|
|
|
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);
|
2017-03-07 09:59:19 +08:00
|
|
|
|
((ComboResultCounter)d).DisplayedCount = CurrentValue;
|
2016-10-16 04:16:02 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|