using asap.core; using cfg; using GameCore; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; public class PlayerGradeReward : MonoBehaviour { PanelScroll scrollRect; Image bar; GameObject gradeItem; List gradeDatas = new List(); float itemHigh = 250; private void Awake() { bar = transform.Find("ScrollView/Viewport/Content/bg_bar/bar").GetComponent(); scrollRect = transform.Find("ScrollView").GetComponent(); gradeItem = transform.Find("ScrollView/Viewport/Content/item").gameObject; gradeItem.SetActive(false); itemHigh = gradeItem.GetComponent().sizeDelta.y; scrollRect.isReversal = true; } private void Start() { gradeDatas.Clear(); var account = GContext.container.Resolve().TBAccount.DataList; int nextIndex = account.Count - 1; for (int i = 0; i < account.Count; i++) { if (GContext.container.Resolve().lv < account[i].ID) { nextIndex = i; break; } } bar.fillAmount = (GContext.container.Resolve().lv - 1) / ((float)account[0].ID - 1); int showCount = nextIndex + 10; if (showCount > account.Count) { showCount = account.Count; } for (int i = 0; i < showCount; i++) { gradeDatas.Add(new GradeItemData() { account = account[i], nextIndex = nextIndex }); } if (nextIndex > 0) { int startLv = account[nextIndex - 1].ID; var nextAccountData = account[nextIndex]; gradeDatas[nextIndex - 1].fillAmount = (GContext.container.Resolve().lv - startLv) / (float)(nextAccountData.ID - startLv); gradeDatas[nextIndex].next = true; nextIndex--; } else if (GContext.container.Resolve().lv < account[0].ID) { gradeDatas[0].next = true; } gradeDatas[^1].bar = false; scrollRect.Init(itemHigh, gradeItem, null, gradeDatas, _currentIndex: nextIndex, _minShowAdd: 3); } }