Пример #1
0
 void Update()
 {
     // check input 0~9
     for (KeyCode i = KeyCode.Alpha0; i <= KeyCode.Alpha9; i++)
     {
         if (Input.GetKeyDown(i))
         {
             IncressScoreboardItem.SetNumber((int)i - 48, Time);
             DecressScoreBoardItem.SetNumber((int)i - 48, Time, false);
         }
     }
 }
Пример #2
0
    /// <summary>
    /// 设置目标数字
    /// </summary>
    public void SetNumber(int number)
    {
        number = Mathf.Clamp(number, 0, _maxNumber);
        bool isIncreasing = number > Number;

        Number = number;

        int unit = Count - 1;   // 位

        while (unit >= 0)
        {
            _numberList[unit--] = number % 10;
            number /= 10;
        }

        for (int i = 0; i < _numberList.Count; i++)
        {
            ScoreboardItem item = _itemList[i];
            item.SetNumber(_numberList[i], 1f, isIncreasing);
        }
    }