少年修仙传客户端代码仓库
Client_PangDeRong
2018-09-21 d1a2ab5b56bae336a1b5cbc4f307cb67e76c22e6
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text.RegularExpressions;
using UnityEngine;
using UnityEngine.UI;
namespace Snxxz.UI
{
    public class DungeonRankBehaviour : MonoBehaviour
    {
        [SerializeField] List<Text> playerNameTexts;
        [SerializeField] List<Text> valueTexts;
        [SerializeField] Text mineRankText;
        [SerializeField] Text mineNameText;
        [SerializeField] Text mineValueText;
 
        int currentDugeonId = 0;
 
        private object RegexPlayerDatas;
 
        DungeonModel model { get { return ModelCenter.Instance.GetModel<DungeonModel>(); } }
 
        public void Init(int mapID)
        {
            currentDugeonId = mapID;
            SetMineInfo(0, 0);
            SetDefault();
            UpdateMissionEvent();
        }
 
        private void OnEnable()
        {
            model.updateMissionEvent += UpdateMissionEvent;
        }
 
        private void UpdateMissionEvent()
        {
            if (currentDugeonId == 0) return;
            switch (currentDugeonId)
            {
                case 31170:
                case DemonJarModel.DEMONJAR_MAPID:
                    {
                        if (model.mission.hurtInfo != null && model.mission.hurtInfo.Length > 0)
                        {
                            int i = 0;
                            for (i = 0; i < model.mission.hurtInfo.Length; i++)
                            {
                                var rank = model.mission.hurtInfo[i].rank;
                                if (rank - 1 < playerNameTexts.Count)
                                {
                                    playerNameTexts[rank - 1].text = model.mission.hurtInfo[i].playerName;
                                    valueTexts[rank - 1].text = UIHelper.ReplaceLargeNum(model.mission.hurtInfo[i].totalHurt);
                                    if (Regex.IsMatch(UIHelper.ServerStringTrim(model.mission.hurtInfo[i].playerName), UIHelper.ServerStringTrim(PlayerDatas.Instance.baseData.PlayerName)))
                                    {
                                        SetMineInfo(rank, model.mission.hurtInfo[i].totalHurt);
                                    }
                                }
                                else
                                {
                                    SetMineInfo(rank, model.mission.hurtInfo[i].totalHurt);
                                }
                            }
                            while (i < playerNameTexts.Count)
                            {
                                playerNameTexts[i].text = string.Empty;
                                valueTexts[i].text = string.Empty;
                                i++;
                            }
                        }
                    }
                    break;
            }
        }
 
        private void SetMineInfo(int rank, long hurt)
        {
            if (mineRankText != null)
            {
                mineRankText.text = rank == 0 ?Language.Get("FamilyMatchUnBeOnList") : StringUtility.Contact(rank, ":");
            }
            if (mineNameText != null)
            {
                mineNameText.text = PlayerDatas.Instance.baseData.PlayerName;
            }
            mineValueText.text = UIHelper.ReplaceLargeNum((ulong)hurt);
        }
 
        private void SetDefault()
        {
            for (int i = 0; i < playerNameTexts.Count; i++)
            {
                playerNameTexts[i].text = string.Empty;
            }
            for (int i = 0; i < valueTexts.Count; i++)
            {
                valueTexts[i].text = string.Empty;
            }
        }
 
        private void OnDisable()
        {
            model.updateMissionEvent -= UpdateMissionEvent;
        }
    }
}