少年修仙传客户端代码仓库
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
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
//--------------------------------------------------------
//    [Author]:           第二世界
//    [  Date ]:           Tuesday, March 12, 2019
//--------------------------------------------------------
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
using UnityEngine.Events;
 
namespace Snxxz.UI
{
 
    public class TipSuitPropertyWidget : MonoBehaviour
    {
        [SerializeField] Text m_SuitName;
        [SerializeField] RectTransform m_StarsContainer;
        [SerializeField] StarToggle[] m_StarToggles;
        [SerializeField] Text[] m_SuitEquipNames;
 
        [SerializeField] EquipSuitPropertyBar m_TwoSuit;
        [SerializeField] EquipSuitPropertyBar m_FiveSuit;
        [SerializeField] Text m_EightSuitTitle;
        [SerializeField] Text m_EightSuitDescription;
 
        ItemTipUtility.SuitInfo suitInfo;
        public void Display(ItemTipUtility.SuitInfo suitInfo)
        {
            this.suitInfo = suitInfo;
 
            m_SuitName.text = suitInfo.name;
 
            var highestEightSuitLevel = 0;
            foreach (var item in suitInfo.eightSuits)
            {
                if (item.Value && item.Key > highestEightSuitLevel)
                {
                    highestEightSuitLevel = item.Key;
                }
            }
 
            var maxLevel = suitInfo.maxSuitLevel;
            m_StarsContainer.gameObject.SetActive(maxLevel >= 0);
            if (maxLevel >= 0)
            {
                m_StarToggles[0].SetActive(true, DisplaySuitInfo);
                m_StarToggles[1].SetActive(maxLevel >= 3, DisplaySuitInfo);
                m_StarToggles[2].SetActive(maxLevel >= 6, DisplaySuitInfo);
                m_StarToggles[3].SetActive(maxLevel >= 9, DisplaySuitInfo);
 
                for (int i = 0; i < m_StarToggles.Length; i++)
                {
                    m_StarToggles[i].toggle.isOn = i == highestEightSuitLevel / 3;
                }
            }
 
            DisplaySuitInfo(highestEightSuitLevel);
        }
 
        void DisplaySuitInfo(int star)
        {
            DisplayCollectInfo(star);
            DisplaySuitProperty(star);
        }
 
        void DisplayCollectInfo(int star)
        {
            var setName = EquipModel.GetSuitName(suitInfo.level);
            for (int i = 0; i < m_SuitEquipNames.Length; i++)
            {
                var place = i + 1;
                m_SuitEquipNames[i].text = setName + EquipSuitNameConfig.GetSuitName(suitInfo.level, place, suitInfo.job);
                var hasSuit = suitInfo.places.Contains(place)
                    && suitInfo.placeStars.ContainsKey(place) && suitInfo.placeStars[place] >= star;
                m_SuitEquipNames[i].color = UIHelper.GetUIColor(hasSuit ? TextColType.Green : TextColType.White, true);
            }
        }
 
        void DisplaySuitProperty(int star)
        {
            m_TwoSuit.Display(suitInfo.twoSuitProperties[star]);
            m_FiveSuit.Display(suitInfo.fiveSuitProperties[star]);
            m_EightSuitDescription.text = GetEightSuitDescription(suitInfo.job, suitInfo.level, star);
            var eightSuitActive = suitInfo.eightSuits[star];
            var color = UIHelper.GetUIColor(eightSuitActive ? TextColType.Green : TextColType.White, true);
            m_EightSuitTitle.color = color;
            m_EightSuitDescription.color = color;
        }
 
        public void Dispose()
        {
 
        }
 
        private string GetEightSuitDescription(int job, int level, int star)
        {
            var configs = EquipSuitConfig.GetConfigs(job, level, EquipSuitType.EightSuit);
            for (int i = 0; i < configs.Count; i++)
            {
                var config = configs[i];
                if (config.star == star)
                {
                    var description = string.Empty;
                    if (config.skillID > 0)
                    {
                        description = config.description;
                    }
                    else
                    {
                        var propertyConfig = PlayerPropertyConfig.Get(config.attr[0].x);
                        var propertyDescription = PlayerPropertyConfig.GetValueDescription(config.attr[0].x, config.attr[0].y);
                        description = StringUtility.Contact(propertyConfig.Name, " +", propertyDescription);
                    }
 
                    return description;
                }
            }
 
            return string.Empty;
        }
 
        [System.Serializable]
        public class StarToggle
        {
            public RectTransform root;
            public int star;
            public Text title;
            public Toggle toggle;
 
            UnityAction<int> action;
 
            public void SetActive(bool active, UnityAction<int> action)
            {
                root.gameObject.SetActive(active);
                toggle.isOn = false;
                toggle.interactable = active;
                this.action = action;
 
                if (active)
                {
                    toggle.SetListener(OnValueChange);
                }
                else
                {
                    toggle.RemoveAllListeners();
                }
            }
 
            private void OnValueChange(bool value)
            {
                if (value)
                {
                    if (action != null)
                    {
                        action(star);
                    }
                }
            }
 
        }
 
 
    }
 
}