| | |
| | | using TableConfig; |
| | | using EnhancedUI.EnhancedScroller; |
| | | |
| | | namespace Snxxz.UI { |
| | | namespace Snxxz.UI
|
| | | { |
| | | //段位奖励
|
| | | [XLua.Hotfix] |
| | | public class SegmentRewardWin : Window |
| | | {
|
| | | [SerializeField] ScrollerController m_ScrollerController;
|
| | | CrossServerRewardModel m_CrossServerRewardModel;
|
| | | CrossServerRewardModel crossServerRewardModel { get { return m_CrossServerRewardModel ?? (m_CrossServerRewardModel = ModelCenter.Instance.GetModel<CrossServerRewardModel>()); } } |
| | | CrossServerRewardModel crossServerRewardModel { get { return m_CrossServerRewardModel ?? (m_CrossServerRewardModel = ModelCenter.Instance.GetModel<CrossServerRewardModel>()); } }
|
| | | List<SeasonAwardClass> ListSort = new List<SeasonAwardClass>(); |
| | | #region Built-in |
| | | protected override void BindController() |
| | | {
|
| | |
| | | |
| | | protected override void OnPreOpen() |
| | | {
|
| | | OnCreateGridLineCell(m_ScrollerController); |
| | | ToAddSorting();
|
| | | OnCreateGridLineCell(m_ScrollerController);
|
| | | m_ScrollerController.JumpIndex(JumpIndex()); |
| | | } |
| | | |
| | | protected override void OnAfterOpen() |
| | | { |
| | | {
|
| | | crossServerRewardModel.CrossRealmPKAwardStateUpdate += CrossRealmPKAwardStateUpdate; |
| | | CrossServerPlayerInfo.Instance.UpdatePlayerInfoEvent += UpdatePlayerInfoEvent; |
| | | } |
| | | |
| | | protected override void OnPreClose() |
| | | { |
| | | } |
| | | |
| | | {
|
| | | crossServerRewardModel.CrossRealmPKAwardStateUpdate -= CrossRealmPKAwardStateUpdate; |
| | | CrossServerPlayerInfo.Instance.UpdatePlayerInfoEvent -= UpdatePlayerInfoEvent; |
| | | }
|
| | |
|
| | |
|
| | |
|
| | | protected override void OnAfterClose() |
| | | { |
| | | }
|
| | | #endregion |
| | | private void UpdatePlayerInfoEvent()
|
| | | {
|
| | | m_ScrollerController.m_Scorller.RefreshActiveCellViews();//刷新可见
|
| | | }
|
| | |
|
| | | private void CrossRealmPKAwardStateUpdate()
|
| | | {
|
| | | m_ScrollerController.m_Scorller.RefreshActiveCellViews();//刷新可见
|
| | | } |
| | | void OnCreateGridLineCell(ScrollerController gridCtrl)
|
| | | {
|
| | | gridCtrl.Refresh();
|
| | | foreach (var key in crossServerRewardModel.SegmentRewardDic.Keys)
|
| | | for (int i = 0; i < ListSort.Count; i++)
|
| | | {
|
| | | gridCtrl.AddCell(ScrollerDataType.Header, key);
|
| | | gridCtrl.AddCell(ScrollerDataType.Header, ListSort[i].DanLv);
|
| | | }
|
| | | gridCtrl.Restart();
|
| | | } |
| | |
| | | int Index = cell.index;
|
| | | SegmentRewardCell segmentRewardCell = cell.GetComponent<SegmentRewardCell>();
|
| | | segmentRewardCell.SetReceive(Index);
|
| | | segmentRewardCell.ReceiveBtn.SetListener(() =>
|
| | | } |
| | | |
| | | private void ToAddSorting()
|
| | | {
|
| | | if (ListSort.Count <= 0)
|
| | | {
|
| | | m_ScrollerController.m_Scorller.RefreshActiveCellViews();//刷新可见
|
| | | });
|
| | | foreach (var key in crossServerRewardModel.SegmentRewardDic.Keys)
|
| | | {
|
| | | ListSort.Add(crossServerRewardModel.SegmentRewardDic[key]);
|
| | | }
|
| | | }
|
| | | ListSort.Sort(Compare);
|
| | | }
|
| | | int Compare(SeasonAwardClass x, SeasonAwardClass y)//数组排列
|
| | | {
|
| | | bool havex1 = IsReceive(x);
|
| | | bool havey1 = IsReceive(y);
|
| | | if (havex1.CompareTo(havey1) != 0)
|
| | | {
|
| | | return -havex1.CompareTo(havey1);
|
| | | }
|
| | | bool havex2 = IsReach(x);
|
| | | bool havey2 = IsReach(y);
|
| | | if (havex2.CompareTo(havey2) != 0)
|
| | | {
|
| | | return -havex2.CompareTo(havey2);
|
| | | }
|
| | | bool havex3 = IsDraw(x);
|
| | | bool havey3 = IsDraw(y);
|
| | | if (havex3.CompareTo(havey3) != 0)
|
| | | {
|
| | | return -havex3.CompareTo(havey3);
|
| | | }
|
| | | if (x.DanLv.CompareTo(y.DanLv) != 0)
|
| | | {
|
| | | return x.DanLv.CompareTo(y.DanLv);
|
| | | }
|
| | | return 1;
|
| | |
|
| | | } |
| | | private bool IsReceive(SeasonAwardClass _seasonAwardClass)//未领取
|
| | | {
|
| | | bool Bool = false;
|
| | | if (CrossServerPlayerInfo.Instance.DanLV >= _seasonAwardClass.DanLv && !crossServerRewardModel.IsAwardState(CrossRealmPKAwardStateEnum.DanLVAwardState, _seasonAwardClass.DanLv))
|
| | | {
|
| | | Bool = true;
|
| | | }
|
| | | return Bool;
|
| | | } |
| | | private bool IsReach(SeasonAwardClass _seasonAwardClass)//未达到
|
| | | {
|
| | | bool Bool = false;
|
| | | if (_seasonAwardClass.DanLv > CrossServerPlayerInfo.Instance.DanLV)
|
| | | {
|
| | | Bool = true;
|
| | | }
|
| | | return Bool;
|
| | | }
|
| | | private bool IsDraw(SeasonAwardClass _seasonAwardClass)//已领取
|
| | | {
|
| | | bool Bool = crossServerRewardModel.IsAwardState(CrossRealmPKAwardStateEnum.DanLVAwardState, _seasonAwardClass.DanLv);
|
| | | return Bool;
|
| | | }
|
| | | private int JumpIndex()
|
| | | {
|
| | | int Index = 0;
|
| | | for (int i = 0; i < ListSort.Count; i++)
|
| | | {
|
| | | if (IsReceive(ListSort[i]))
|
| | | {
|
| | | Index = i;
|
| | | return Index;
|
| | | }
|
| | | }
|
| | | return Index;
|
| | | }
|
| | | } |
| | | |
| | | } |