private void OnStatusFilterChanged(bool all) { _currentList = all ? _players : _sameStatusPlayers; SortPlayers(); for (int i = 0; i < topCount; i++) { if (i < _currentList.Count) { if (i >= _usersPool.Active.Count) { TopUser newUser = _usersPool.GetItemFromPool(); if (newUser == null) { return; } newUser.Activate(newUser.transform.position); } _usersPool.Active[i].SetData(_currentList[i], _currentDifficulty); _usersPool.Active[i].SetIndex(i + 1); } else { if (_usersPool.Active.Count <= i) { break; } _usersPool.ReturnItemToPool(_usersPool.Active[i]); i--; } } _ui.ChangeTableHeight(_currentList.Count > topCount ? topCount : _currentList.Count); _ui.ChangeScrollValue(CalculateScrollValue()); }
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()); }