1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-15 07:27:33 +08:00
osu-lazer/osu.Game/GameModes/Play/ComboResultCounter.cs
Dean Herbert 43f0409893 Start to structure flow of information in Player.
- Allow basic clicking of hitobjects.
- Break non-osu! game modes temporarily.
- Fix some issues with RollingCounters.
- Add the ability to increment counters.
2016-10-19 19:44:03 +09:00

69 lines
2.1 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 osu.Framework.Graphics;
using osu.Framework.Graphics.Transformations;
using osu.Framework.MathUtils;
using osu.Framework.Timing;
using osu.Game.Graphics.UserInterface;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace osu.Game.GameModes.Play
{
/// <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);
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)
{
Count = Count + amount;
}
protected class TransformComboResult : Transform<ulong>
{
public override ulong CurrentValue
{
get
{
double time = Time;
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);
(d as ComboResultCounter).DisplayedCount = CurrentValue;
}
public TransformComboResult(IClock clock)
: base(clock)
{
}
}
}
}