少年修仙传客户端代码仓库
lcy
2024-12-16 a39c35fc6449430cd02bccb681c4a0a880e46cd9
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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
//--------------------------------------------------------
//    [Author]:           第二世界
//    [  Date ]:           Friday, April 26, 2019
//--------------------------------------------------------
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using UnityEngine.UI;
using System;
 
namespace vnxbqy.UI
{
    public class OtherPlayerSuitWidget : MonoBehaviour
    {
        [SerializeField] Text m_SuitName;
        [SerializeField] StarToggle[] m_StarToggles;
        [SerializeField] Text[] m_SuitEquipNames;
 
        [SerializeField] EquipSuitPropertyBar m_TwoSuit;
        [SerializeField] EquipSuitPropertyBar m_FiveSuit;
        [SerializeField] Text m_EightSuitTitle;
        [SerializeField] Text m_EightSuitDescription;
 
        Dictionary<int, int> placeStars;
        int level;
        int job;
        int twoSuitLevel;
        int fiveSuitLevel;
        int eightSuitLevel;
 
        public void Display(OtherPlayerEquipModel.SuitInfo suitInfo)
        {
            placeStars = suitInfo.placeStars;
            level = suitInfo.level;
            job = suitInfo.job;
            twoSuitLevel = suitInfo.suitLevels[EquipSuitType.TwoSuit];
            fiveSuitLevel = suitInfo.suitLevels[EquipSuitType.FiveSuit];
            eightSuitLevel = suitInfo.suitLevels[EquipSuitType.EightSuit];
 
            m_SuitName.text = EquipSuitConfig.GetConfigs(job, level, EquipSuitType.TwoSuit)[0].name;
            var maxLevel = EquipStarModel.GetMaxStarLevel(level);
            m_StarToggles[3].SetActive(maxLevel >= 9);
            m_StarToggles[2].SetActive(maxLevel >= 6);
            m_StarToggles[1].SetActive(maxLevel >= 3);
            m_StarToggles[0].SetActive(true);
 
            m_StarToggles[3].AddListener(() => { DisplaySuitInfo(9); });
            m_StarToggles[2].AddListener(() => { DisplaySuitInfo(6); });
            m_StarToggles[1].AddListener(() => { DisplaySuitInfo(3); });
            m_StarToggles[0].AddListener(() => { DisplaySuitInfo(0); });
 
            m_StarToggles[0].Select();
            DisplaySuitInfo(0);
        }
 
        void DisplaySuitInfo(int star)
        {
            DisplaySuitCollections(star);
            DisplayProperty(star);
        }
 
        void DisplaySuitCollections(int star)
        {
            for (int i = 1; i <= 8; i++)
            {
                var hasSuit = placeStars.ContainsKey(i) && placeStars[i] >= star;
                m_SuitEquipNames[i - 1].color = UIHelper.GetUIColor(hasSuit ? TextColType.Green : TextColType.White, true);
                m_SuitEquipNames[i - 1].text = UIHelper.GetEquipPlaceName(i);
            }
        }
 
        void DisplayProperty(int star)
        {
            var twoConfigs = EquipSuitConfig.GetConfigs(PlayerDatas.Instance.baseData.Job, level, EquipSuitType.TwoSuit);
            var fiveConfigs = EquipSuitConfig.GetConfigs(PlayerDatas.Instance.baseData.Job, level, EquipSuitType.FiveSuit);
            var eightConfigs = EquipSuitConfig.GetConfigs(PlayerDatas.Instance.baseData.Job, level, EquipSuitType.EightSuit);
 
            var config = twoConfigs.Find(x => { return x.star == star; });
            var properties = new List<Int2>();
            var twoSuit = new EquipSuitPropertyEntry()
            {
                type = EquipSuitType.TwoSuit,
                actived = twoSuitLevel >= star,
                properties = new List<Int2>(config.attr),
            };
 
            config = fiveConfigs.Find(x => { return x.star == star; });
            properties = new List<Int2>();
            var fiveSuit = new EquipSuitPropertyEntry()
            {
                type = EquipSuitType.FiveSuit,
                actived = fiveSuitLevel >= star,
                properties = new List<Int2>(config.attr),
            };
 
            config = eightConfigs.Find(x => { return x.star == star; });
 
            m_TwoSuit.Display(twoSuit, true);
            m_FiveSuit.Display(fiveSuit, true);
            m_EightSuitDescription.text = GetEightSuitDescription(config.id);
            var color = UIHelper.GetUIColor(eightSuitLevel >= star ? TextColType.Green : TextColType.White, true);
            m_EightSuitTitle.color = color;
            m_EightSuitDescription.color = color;
        }
 
        public void Dispose()
        {
 
        }
 
        private string GetEightSuitDescription(int suitId)
        {
            var config = EquipSuitConfig.Get(suitId);
            if (config.skillID > 0)
            {
                return config.description;
            }
            else
            {
                return PlayerPropertyConfig.GetFullDescription(config.attr[0]);
            }
        }
 
        [System.Serializable]
        public class StarToggle
        {
            public int star;
            public Text title;
            public Toggle toggle;
 
            Action onSelect;
 
            public void SetActive(bool active)
            {
                title.SetActive(active);
                toggle.interactable = active;
                if (active)
                {
                    toggle.SetListener(OnValueChange);
                }
                else
                {
                    toggle.RemoveAllListeners();
                }
            }
 
            public void Select()
            {
                toggle.isOn = true;
            }
 
            public void AddListener(Action callBack)
            {
                onSelect = callBack;
            }
 
            private void OnValueChange(bool value)
            {
                if (value)
                {
                    if (onSelect != null)
                    {
                        onSelect();
                    }
                }
            }
 
        }
 
    }
 
}