少年修仙传客户端代码仓库
client_Wu Xijin
2019-06-13 033958214c0b16d7e7b93cc821b018c295251867
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using System;
 
 
namespace Snxxz.UI
{
    public class DungeonIntegralRankBehaviour : MonoBehaviour
    {
        [SerializeField] ScrollerController scrollerController;
        [SerializeField] Text m_SelfRankTxt;
        [SerializeField] Text m_SelfNameTxt;
        [SerializeField] Text m_SelfIntegralTxt;
        [SerializeField] AwardItemUI m_AwardItem;
        FairyLeagueModel m_FairyLeagueModel;
        FairyLeagueModel fairyLeagueModel
        {
            get
            {
                return m_FairyLeagueModel ?? (m_FairyLeagueModel = ModelCenter.Instance.GetModel<FairyLeagueModel>());
            }
        }
 
        private void OnEnable()
        {
            fairyLeagueModel.UpdateWarRankEvent += RefreshRank;
            RefreshRank();
        }
 
        private void RefreshRank()
        {
            scrollerController.Refresh();
            for (int i = 0; i < fairyLeagueModel.fairyLeagueResults.Count; i++)
            {
                scrollerController.AddCell(ScrollerDataType.Header, i);
            }
            scrollerController.Restart();
            RefreshSelf();
        }
 
        private void RefreshSelf()
        {
            var _index = fairyLeagueModel.fairyLeagueResults.FindIndex((x) =>
            {
                return x.PlayerId == PlayerDatas.Instance.PlayerId;
            });
            if (_index != -1)
            {
                m_SelfRankTxt.text = (_index + 1).ToString();
                m_SelfIntegralTxt.text = fairyLeagueModel.fairyLeagueResults[_index].Integral.ToString();
                m_SelfNameTxt.text = fairyLeagueModel.fairyLeagueResults[_index].PlayerName;
            }
            else
            {
                m_SelfRankTxt.text = Language.Get("FamilyMatchUnBeOnList");
                m_SelfIntegralTxt.text = "0";
                m_SelfNameTxt.text = PlayerDatas.Instance.baseData.PlayerName;
            }
            var rankKey = UIHelper.GetIntervalAward(fairyLeagueModel.integralRankAwardDict.Keys, _index + 1);
            if (rankKey != -1)
            {
                var _item = fairyLeagueModel.integralRankAwardDict[rankKey][0];
                var _per = 100;
                if ((fairyLeagueModel.fairyLeagueGroupId - 1) >= 0
                    && (fairyLeagueModel.fairyLeagueGroupId - 1) < fairyLeagueModel.integralRankAwardPer.Length)
                {
                    _per = fairyLeagueModel.integralRankAwardPer[fairyLeagueModel.fairyLeagueGroupId - 1];
                }
                var _count = (int)Mathf.Max(_item.count * (_item.isPer == 1 ? ((float)_per / 100) : 1), 1);
                m_AwardItem.Init(_item.id, _count, _item.bind);
            }
        }
 
        private void OnDisable()
        {
            fairyLeagueModel.UpdateWarRankEvent -= RefreshRank;
        }
    }
}