少年修仙传客户端代码仓库
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
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
 
namespace vnxbqy.UI
{
    public class RealmLevelUpBehaviour : MonoBehaviour
    {
        [SerializeField] Transform m_ContainerCondition;
        [SerializeField] RealmUpCondition m_LevelCondition;
        [SerializeField] RealmUpCondition m_BossCondition;
        [SerializeField] RealmEquipCondition m_EquipCondition;
        [SerializeField] Transform m_ContainerCost;
        [SerializeField] ItemBehaviour m_Item;
        [SerializeField] Text m_RequireRealmLevel;
        [SerializeField] Button m_LevelUp;
 
        int realmLevel = 0;
 
        RealmModel model { get { return ModelCenter.Instance.GetModel<RealmModel>(); } }
        PackModel packModel { get { return ModelCenter.Instance.GetModel<PackModel>(); } }
 
        private void Awake()
        {
            m_LevelUp.AddListener(OnLevelUp);
        }
 
        public void Display(int realmLevel)
        {
            this.realmLevel = realmLevel;
            var currentRealmLevel = model.displayRealmLevel;
            var isNext = realmLevel == currentRealmLevel + 1;
            m_ContainerCondition.SetActive(isNext);
            m_ContainerCost.SetActive(isNext);
            m_LevelUp.SetActive(isNext);
            m_RequireRealmLevel.SetActive(!isNext);
 
            if (isNext)
            {
                DisplayCondition();
                DisplayCost();
            }
            else
            {
                var config = RealmConfig.Get(realmLevel - 1);
                m_RequireRealmLevel.text = Language.Get("RealmLevelUpRequire", config.Img);
            }
        }
 
        public void DisplayCondition()
        {
            var config = RealmConfig.Get(realmLevel - 1);
            m_LevelCondition.DisplayLevel(realmLevel - 1);
            m_BossCondition.SetActive(config.BossID != 0);
            m_EquipCondition.SetActive(model.HasEquipCondition(realmLevel - 1));
            if (config.BossID != 0)
            {
                m_BossCondition.DisplayBoss(realmLevel - 1);
            }
            if (model.HasEquipCondition(realmLevel - 1))
            {
                m_EquipCondition.DisplayLevel(realmLevel - 1);
            }
        }
 
        public void DisplayCost()
        {
            var config = RealmConfig.Get(realmLevel - 1);
            m_ContainerCost.SetActive(config.NeedGood != 0 && config.NeedNum != 0);
            m_Item.SetItem(config.NeedGood, config.NeedNum);
        }
 
        private void OnLevelUp()
        {
            var error = 0;
            if (model.TryLevelUp(out error))
            {
                var config = RealmConfig.Get(PlayerDatas.Instance.baseData.realmLevel);
                LimitedTimeLuxuryGiftModel.Instance.IsItemIdShow(23, config.NeedGood, config.NeedNum, 1, 0);
                CA523_tagCMRealmLVUp pak = new CA523_tagCMRealmLVUp();
                GameNetSystem.Instance.SendInfo(pak);
            }
            else
            {
                DisplayErrorTip(error);
            }
            
        }
 
        void DisplayErrorTip(int error)
        {
            switch (error)
            {
                case 1:
                    SysNotifyMgr.Instance.ShowTip("RealmLevelUpError_1");
                    break;
                case 2:
                    SysNotifyMgr.Instance.ShowTip("RealmLevelUpError_2");
                    break;
                case 3:
                    var config = RealmConfig.Get(PlayerDatas.Instance.baseData.realmLevel);
                    ItemTipUtility.Show(config.NeedGood);
                    break;
                case 4:
                    model.realmUpgrateNoEnoughReason = 1;
                    WindowCenter.Instance.Open<RealmRecommandEquipWin>();
                    break;
                case 5:
                    model.realmUpgrateNoEnoughReason = 2;
                    WindowCenter.Instance.Open<RealmRecommandEquipWin>();
                    break;
            }
        }
    }
 
    [Serializable]
    public class RealmUpCondition
    {
        [SerializeField] Transform m_Container;
        [SerializeField] Text m_Condition;
        [SerializeField] Text m_Progress;
 
        RealmModel model { get { return ModelCenter.Instance.GetModel<RealmModel>(); } }
 
        public void DisplayLevel(int realmLevel)
        {
            var config = RealmConfig.Get(realmLevel);
            m_Condition.text = Language.Get("RealmConditionLevel", config.NeedLV);
            var level = PlayerDatas.Instance.baseData.LV;
            var satisfy = level >= config.NeedLV;
            m_Progress.text = StringUtility.Contact(level, "/", config.NeedLV);
            m_Progress.color = satisfy ? UIHelper.s_LightGreen : UIHelper.s_DarkRedColor;
        }
 
        public void DisplayBoss(int realmLevel)
        {
            var config = RealmConfig.Get(realmLevel + 1);
            var label = UIHelper.GetRealmColorByLv(realmLevel + 1, StringUtility.Contact("[", config.Name, "]"));
            m_Condition.text = Language.Get("RealmConditionBoss", label);
            var progress = model.isBossPass ? 1 : 0;
            m_Progress.text = StringUtility.Contact(progress, "/", 1);
            m_Progress.color = model.isBossPass ? UIHelper.s_LightGreen : UIHelper.s_DarkRedColor;
        }
 
        public void SetActive(bool active)
        {
            m_Container.SetActive(active);
        }
    }
 
    [Serializable]
    public class RealmEquipCondition
    {
        [SerializeField] Transform m_Container;
        [SerializeField] Text m_Condition;
        [SerializeField] Text m_Progress;
        [SerializeField] Text[] m_EquipPlaceNames;
 
        readonly Color s_Gray = new Color32(189, 189, 189, 255);
 
        RealmModel model { get { return ModelCenter.Instance.GetModel<RealmModel>(); } }
        EquipModel equipModel { get { return ModelCenter.Instance.GetModel<EquipModel>(); } }
        PackModel packModel { get { return ModelCenter.Instance.GetModel<PackModel>(); } }
 
        public void DisplayLevel(int realmLevel)
        {
            RealmLevelUpEquipCondition equipCondition;
            if (model.TryGetRealmEquipCondition(realmLevel, out equipCondition))
            {
                var equipSet = equipModel.GetEquipSet(equipCondition.level);
                var realmConfig = RealmConfig.Get(equipSet.realm);
                if (!equipCondition.isSuit)
                {
                    var colorName = UIHelper.GetColorNameByItemColor(equipCondition.itemColor);
                    m_Condition.text = Language.Get("RealmNeedEquipCondition_1", realmConfig.Name, colorName, equipCondition.starLevel, 8);
                }
                else
                {
                    m_Condition.text = Language.Get("RealmNeedEquipCondition_2", realmConfig.Name, equipCondition.starLevel, 8);
                }
 
                List<int> notSatisfyPlaces;
                model.SatisfyEquipCondition(realmLevel, out notSatisfyPlaces);
 
                var progress = 8 - notSatisfyPlaces.Count;
                for (int i = 0; i < m_EquipPlaceNames.Length; i++)
                {
                    var place = i + 1;
                    m_EquipPlaceNames[i].text = UIHelper.GetEquipPlaceName(place);
                    bool satisfy = !notSatisfyPlaces.Contains(place);
                    m_EquipPlaceNames[i].color = satisfy ? UIHelper.s_LightGreen : s_Gray;
                }
 
                m_Progress.text = StringUtility.Contact(progress, "/", 8);
                m_Progress.color = progress >= 8 ? UIHelper.s_LightGreen : UIHelper.s_DarkRedColor;
            }
        }
 
        public void SetActive(bool active)
        {
            m_Container.SetActive(active);
        }
    }
}