113 lines
2.7 KiB
C#
113 lines
2.7 KiB
C#
|
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<int> _RewIdList;
|
|||
|
void InitRewItemContainer()
|
|||
|
{
|
|||
|
var _AllTab = TableManager.GetChallengeOnceReward();
|
|||
|
_RewIdList = new List<int>();
|
|||
|
foreach (var tab in _AllTab)
|
|||
|
{
|
|||
|
_RewIdList.Add(tab.Key);
|
|||
|
}
|
|||
|
|
|||
|
_RewItemContainer.InitContentItem(_RewIdList);
|
|||
|
}
|
|||
|
|
|||
|
//排序
|
|||
|
Dictionary<int, int> _AllRewStateDic = new Dictionary<int, int>();
|
|||
|
public void OnPacket(RetChallengeRewardList packet)
|
|||
|
{
|
|||
|
_AllRewStateDic = new Dictionary<int, int>();
|
|||
|
for(int index = 0; index < packet.rewardList.Count; index++)
|
|||
|
{
|
|||
|
_AllRewStateDic.Add(index + 1 , packet.rewardList[index]);
|
|||
|
}
|
|||
|
|
|||
|
List<KeyValuePair<int, int>> keyValList = new List<KeyValuePair<int, int>>(_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<int> rewLis = new List<int>();
|
|||
|
for(int index = 0; index < keyValList.Count; index++)
|
|||
|
{
|
|||
|
rewLis.Add(keyValList[index].Key);
|
|||
|
}
|
|||
|
|
|||
|
_RewItemContainer.InitContentItem(rewLis);
|
|||
|
_RewItemContainer.ForeachActiveItem<FactionRewItem>((item) => {
|
|||
|
if(_AllRewStateDic.ContainsKey(item._CurRewId))
|
|||
|
{
|
|||
|
item.RefreshState(_AllRewStateDic[item._CurRewId]);
|
|||
|
}
|
|||
|
});
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
public void OnClose()
|
|||
|
{
|
|||
|
UIManager.CloseUI(UIInfo.FactionRankRewPanel);
|
|||
|
}
|
|||
|
}
|