Nicer generic rolling counters

This commit is contained in:
Thomas Müller
2017-07-14 19:14:07 +03:00
parent b5fbb26f8f
commit fd58c6e835
5 changed files with 34 additions and 102 deletions

View File

@ -10,8 +10,6 @@ namespace osu.Game.Graphics.UserInterface
{
public class ScoreCounter : RollingCounter<double>
{
protected override Type TransformType => typeof(TransformScore);
protected override double RollingDuration => 1000;
protected override EasingTypes RollingEasing => EasingTypes.Out;
@ -55,23 +53,5 @@ namespace osu.Game.Graphics.UserInterface
{
Current.Value = Current + amount;
}
protected class TransformScore : Transform<double, Drawable>
{
public virtual double CurrentValue
{
get
{
double time = Time?.Current ?? 0;
if (time < StartTime) return StartValue;
if (time >= EndTime) return EndValue;
return Interpolation.ValueAt(time, (float)StartValue, (float)EndValue, StartTime, EndTime, Easing);
}
}
public override void Apply(Drawable d) => ((ScoreCounter)d).DisplayedCount = CurrentValue;
public override void ReadIntoStartValue(Drawable d) => StartValue = ((ScoreCounter)d).DisplayedCount;
}
}
}