Exemplo n.º 1
0
        public static IEnumerator LerpAmount(this Text text, string format, NumberFormats.Format numberType, UInt128 to, float duration)
        {
            NumberFormats.TryParse(text.text.ToLower().Replace(",", "").Replace("$", "").Replace("x", ""), numberType, out UInt128 from);
            var start = DateTime.UtcNow;

            for (;;)
            {
                var elapsed = (float)(DateTime.UtcNow - start).TotalSeconds;
                var percent = Curve.Evaluate(elapsed / duration);
                var normed  = UInt128.Lerp(from, to, percent);
                text.SetAmount(format, numberType, normed);
                if (elapsed >= duration)
                {
                    yield break;
                }
                yield return(null);
            }
        }
Exemplo n.º 2
0
 public static void SetAmount(this Text text, string format, NumberFormats.Format numberType, long to)
 {
     text.text = string.Format(format, numberType.FormatAmount(to));
 }