using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; using GCGame.Table; public class FactionRankRewPanel : MonoBehaviour { public static FactionRankRewPanel Instance; private void Awake() { Instance = this; } private void OnDestroy() { Instance = null; } private void OnEnable() { InitRewItemContainer(); ReqRewStateList(); } public Text _Rank; public UIContainerBase _RewItemContainer; public void InitRank(int rank) { _Rank.text = rank + ""; } void ReqRewStateList() { ReqChallengeRewardList req = new ReqChallengeRewardList(); req.flag = 1; req.SendMsg(); } private List _RewIdList; void InitRewItemContainer() { var _AllTab = TableManager.GetChallengeOnceReward(); _RewIdList = new List(); foreach (var tab in _AllTab) { _RewIdList.Add(tab.Key); } _RewItemContainer.InitContentItem(_RewIdList); } //排序 Dictionary _AllRewStateDic = new Dictionary(); public void OnPacket(RetChallengeRewardList packet) { _AllRewStateDic = new Dictionary(); for(int index = 0; index < packet.rewardList.Count; index++) { _AllRewStateDic.Add(index + 1 , packet.rewardList[index]); } List> keyValList = new List>(_AllRewStateDic); keyValList.Sort((dicA, dicB) => { if(dicA.Value == dicB.Value) { return dicA.Key < dicB.Key ? -1 : 1; }else { if(dicA.Value == 1) { return -1; }else if(dicA.Value == 2) { if(dicB.Value == 1) { return 1; }else if(dicB.Value == 0) { return -1; } }else { return 1; } } return 0; }); List rewLis = new List(); for(int index = 0; index < keyValList.Count; index++) { rewLis.Add(keyValList[index].Key); } _RewItemContainer.InitContentItem(rewLis); _RewItemContainer.ForeachActiveItem((item) => { if(_AllRewStateDic.ContainsKey(item._CurRewId)) { item.RefreshState(_AllRewStateDic[item._CurRewId]); } }); } public void OnClose() { UIManager.CloseUI(UIInfo.FactionRankRewPanel); } }