Esempio n. 1
0
 private float CalculateScrollValue()
 {
     _mainUser.SetIndex(_currentList.IndexOf(_mainUser.Data) + 1);
     if (_mainUser.Index == 1)
     {
         return(1f);
     }
     else if (_mainUser.Index == _currentList.Count)
     {
         return(0f);
     }
     else
     {
         float result = 100 - (float)((float)_mainUser.Index / (float)((float)_currentList.Count / 100));
         return(result / 100);
     }
 }
Esempio n. 2
0
        private void SetDataToUsers()
        {
            TopUser       user = null;
            RectTransform rect = null;

            _usersPool.ReturnAllItemsToPool();
            for (int i = 0; i < topCount; i++)
            {
                user = _usersPool.GetItemFromPool();
                if (user == null)
                {
                    return;
                }
                user.SetData(_currentList[i], _currentDifficulty, true);
                user.SetIndex(i + 1);
                rect = user.GetComponent <RectTransform>();
                rect.localPosition = new Vector3(0, rect.localPosition.y - (_ui.TableCellHeight * (user.Index - 1)), 0);
                user.Activate(user.transform.position);
            }
            _ui.ChangeTableHeight(_currentList.Count > topCount ? topCount : _currentList.Count);
            _ui.ChangeScrollValue(CalculateScrollValue());
        }