少年修仙传客户端代码仓库
client_linchunjie
2019-04-17 f1f2599ba0e6b64358ffef7ae5c9f9af3ed8b8b4
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
//--------------------------------------------------------
//    [Author]:           第二世界
//    [  Date ]:           Friday, March 08, 2019
//--------------------------------------------------------
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
 
namespace Snxxz.UI
{
 
    public class EquipTrainPropertyBarBehaviour : MonoBehaviour
    {
        [SerializeField] int m_Index;
        [SerializeField] Text m_PropertyName;
        [SerializeField] Text m_Value;
        [SerializeField] Slider m_Progress;
        [SerializeField] Text m_DeltaValue;
        [SerializeField] ToggleButton m_Inevitable;
 
        EquipTrainModel model { get { return ModelCenter.Instance.GetModel<EquipTrainModel>(); } }
 
        EquipTrainPropertyBar propertyBar;
 
        public void Display(EquipTrainPropertyBar propertyBar)
        {
            this.propertyBar = propertyBar;
 
            DisplayBaseInfo();
            DisplayDynamicInfo(true);
 
            m_Inevitable.SetListener(SwitchInevitable);
        }
 
        private void LateUpdate()
        {
            DisplayDynamicInfo(false);
        }
 
        private void DisplayBaseInfo()
        {
            var config = PlayerPropertyConfig.Get(propertyBar.propertyId);
            m_PropertyName.text = config.Name;
 
            switch (propertyBar.trainState)
            {
                case EquipTrainModel.TrainState.Empty:
                    m_Progress.value = 0;
                    m_Value.text = "0";
                    m_DeltaValue.gameObject.SetActive(false);
                    m_Inevitable.gameObject.SetActive(true);
                    break;
                case EquipTrainModel.TrainState.StarLimit:
                    m_Progress.value = 1;
                    m_Value.text = string.Format("{0}/{1}", propertyBar.propertyValue, propertyBar.upperLimit);
                    m_DeltaValue.gameObject.SetActive(true);
                    m_Inevitable.gameObject.SetActive(true);
                    break;
                case EquipTrainModel.TrainState.MaxLevel:
                    m_Progress.value = 1;
                    m_Value.text = string.Format("{0}/{1}", propertyBar.propertyValue, propertyBar.upperLimit);
                    m_DeltaValue.gameObject.SetActive(true);
                    m_Inevitable.gameObject.SetActive(false);
                    break;
                case EquipTrainModel.TrainState.Allowable:
                    m_Inevitable.gameObject.SetActive(true);
                    m_DeltaValue.gameObject.SetActive(true);
                    break;
            }
 
        }
 
        private void DisplayDynamicInfo(bool force)
        {
            if (force || propertyBar.propertyValue.dirty)
            {
                var value = propertyBar.propertyValue.Fetch();
                var maxValue = propertyBar.upperLimit;
                m_Value.text = string.Format("{0}/{1}", value, maxValue);
                m_Progress.value = Mathf.Clamp01((float)value / maxValue);
            }
 
            if (force || propertyBar.deltaValue.dirty || propertyBar.operateType.dirty || propertyBar.inevitable.dirty)
            {
                var deltaValue = propertyBar.deltaValue.Fetch();
                var operateType = propertyBar.operateType.Fetch();
                var inevitable = propertyBar.inevitable.Fetch();
 
                m_Inevitable.isOn = inevitable;
 
                var isPerfect = propertyBar.upperLimit > 0 && propertyBar.propertyValue.value >= propertyBar.upperLimit;
                if (isPerfect)
                {
                    m_DeltaValue.text = "完美";
                    m_DeltaValue.color = UIHelper.GetUIColor(TextColType.Green, true);
                }
                else
                {
                    if (operateType == EquipTrainModel.TrainOperateType.Train)
                    {
                        m_DeltaValue.text = inevitable ? "必增" : "";
                        m_DeltaValue.color = UIHelper.GetUIColor(TextColType.Green, true);
                    }
                    else if (operateType == EquipTrainModel.TrainOperateType.Save)
                    {
                        if (deltaValue > 0)
                        {
                            m_DeltaValue.text = string.Format("+{0}", deltaValue);
                            m_DeltaValue.color = UIHelper.GetUIColor(TextColType.Green, true);
                        }
                        else if (deltaValue < 0)
                        {
                            m_DeltaValue.text = deltaValue.ToString();
                            m_DeltaValue.color = UIHelper.GetUIColor(TextColType.Red, true);
                        }
                        else
                        {
                            m_DeltaValue.text = string.Format("+{0}", deltaValue);
                            m_DeltaValue.color = UIHelper.GetUIColor(TextColType.Green, true);
                        }
                    }
                    else
                    {
                        m_DeltaValue.text = "";
                    }
                }
 
            }
 
        }
 
        private void SwitchInevitable()
        {
            switch (propertyBar.trainState)
            {
                case EquipTrainModel.TrainState.Empty:
                    SysNotifyMgr.Instance.ShowTip("Wash_NoEquip1");
                    break;
                case EquipTrainModel.TrainState.StarLimit:
                    SysNotifyMgr.Instance.ShowTip("WashStarRequirement");
                    break;
                case EquipTrainModel.TrainState.Allowable:
                    model.SetInevitable(m_Index - 1, !propertyBar.inevitable.value);
                    break;
                case EquipTrainModel.TrainState.MaxLevel:
                    break;
            }
        }
 
    }
 
}