少年修仙传客户端代码仓库
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
165
166
167
168
169
//--------------------------------------------------------
//    [Author]:           第二世界
//    [  Date ]:           Saturday, January 06, 2018
//--------------------------------------------------------
 
using System;
using System.Collections;
using System.Collections.Generic;
 
using UnityEngine;
using UnityEngine.UI;
 
namespace Snxxz.UI
{
 
    public class TitleDetailsWin : Window
    {
        [SerializeField] List<PropertyBehaviour> m_Propertys;
        [SerializeField] Text m_TitleDescription;
        [SerializeField] Text m_TitleTime;
        [SerializeField] Image m_TitleIcon;
        [SerializeField] RectTransform m_ContainerSkill;
        [SerializeField] Text m_SkillDescription;
        [SerializeField] Button m_CloseBtn;
 
        [SerializeField, Header("技能名字色")] string m_SkillNameHexColor;
 
        TitleModel m_Model;
        TitleModel model
        {
            get
            {
                return m_Model ?? (m_Model = ModelCenter.Instance.GetModel<TitleModel>());
            }
        }
 
        DienstgradConfig titleConfig = null;
        #region Built-in
        protected override void BindController()
        {
        }
 
        protected override void AddListeners()
        {
            m_CloseBtn.onClick.AddListener(CloseClick);
        }
 
        protected override void OnPreOpen()
        {
            titleConfig = DienstgradConfig.Get(model.presentSelectTitle);
            if (titleConfig == null)
            {
                return;
            }
            DisplayTitleTime();
            DisplayTitle();
            DisplayProperty();
            DisplaySkill();
        }
 
        protected override void OnAfterOpen()
        {
        }
 
        protected override void OnPreClose()
        {
        }
 
        protected override void OnAfterClose()
        {
        }
 
        float timer = 0f;
        float delay = 0.5f;
        protected override void LateUpdate()
        {
            base.LateUpdate();
            if (titleConfig == null || titleConfig.Prescription == 0)
            {
                return;
            }
            timer += Time.deltaTime;
            if (timer >= delay)
            {
                timer = 0;
                DisplayTitleTime();
            }
        }
        #endregion
 
        private void DisplayTitle()
        {
            m_TitleIcon.SetSprite(titleConfig.Image);
            m_TitleDescription.text = titleConfig.Content;
        }
 
        private void DisplayTitleTime()
        {
            if (!model.IsTitleGain(model.presentSelectTitle))
            {
                m_TitleTime.text = Language.Get("L1057");
                m_TitleTime.color = UIHelper.GetUIColor(TextColType.Red);
            }
            else
            {
                m_TitleTime.color = UIHelper.GetUIColor(TextColType.Green);
                TitleData title = model.GetGainTitle(model.presentSelectTitle);
                if (titleConfig.Prescription == 0)
                {
                    m_TitleTime.text = Language.Get("L1058");
                    if (!titleConfig.OutTimeDesc.Equals(string.Empty))
                    {
                        m_TitleTime.text = titleConfig.OutTimeDesc;
                    }
                }
                else
                {
                    int surplusSeconds = model.GetTitleSurplusSeconds(model.presentSelectTitle);
                    if (surplusSeconds > 0)
                    {
                        m_TitleTime.text = StringUtility.Contact(TimeUtility.SecondsToTitleDHMS(surplusSeconds), Language.Get("TitleCoolDown"));
                    }
                    else
                    {
                        m_TitleTime.text = Language.Get("TitleOutTime");
                        m_TitleTime.color = UIHelper.GetUIColor(TextColType.Red);
                    }
                }
            }
        }
 
        private void DisplayProperty()
        {
            int[] _types = titleConfig.LightType;
            int[] _values = titleConfig.LightAttribute;
            for (int i = 0; i < m_Propertys.Count; i++)
            {
                if (_types == null || i >= _types.Length)
                {
                    m_Propertys[i].gameObject.SetActive(false);
                }
                else
                {
                    m_Propertys[i].gameObject.SetActive(true);
                    m_Propertys[i].DisplayUpper(_types[i], _values[i]);
                }
            }
        }
 
        private void DisplaySkill()
        {
            var _skills = titleConfig.Skills;
            m_ContainerSkill.gameObject.SetActive(_skills != null && _skills.Length > 0);
            if (_skills != null && _skills.Length > 0)
            {
                var skill = _skills[0];
                var config = SkillConfig.Get(skill);
                if (config != null)
                {
                    m_SkillDescription.text = StringUtility.Contact("<color=#", m_SkillNameHexColor, ">", config.SkillName, ":", "</color>", config.Description);
                }
            }
        }
    }
}