少年修仙传客户端代码仓库
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
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using LitJson;
 
namespace vnxbqy.UI
{
    public class RealmBriefBehaviour : MonoBehaviour
    {
        [SerializeField] Image m_Icon;
        [SerializeField] PropertyBehaviour m_ClonePropertyBeha;
        [SerializeField] Transform m_PropertyRoot;
        [SerializeField] List<PropertyBehaviour> m_Properties;
        [SerializeField] Transform m_ContainerReiki;
        [SerializeField] Text m_ReikiPoint;
        [SerializeField] Text m_OnHookMaxTime;
        [SerializeField] Transform m_ContainerSkill;
        [SerializeField] Text m_SkillName;
        [SerializeField] Button m_ViewDetail;  
        [SerializeField] Image m_SkillIcon;
 
        [SerializeField] Transform m_ContainerUnlockEquip;
        [SerializeField] Image m_UnlockEquip;
        [SerializeField] Button m_Preview;
 
 
        int realmLevel = 0;
 
        RealmModel model { get { return ModelCenter.Instance.GetModel<RealmModel>(); } }
 
        OffLineOnHookModel onHookModel { get { return ModelCenter.Instance.GetModel<OffLineOnHookModel>(); } }
 
        private void Awake()
        {
            m_Preview.AddListener(OnEquipPreview);
        }
 
        public void Display(int realmLevel)
        {
            this.realmLevel = realmLevel;
            CreatePropertyBehaviour();
            DisplayBase();
            DisplayProperty();
            DisplayEquip();
            DisplaySkill();
            DisplayReiki();
        }
 
        void DisplayBase()
        {
            if (realmLevel > 0 && RealmConfig.Has(realmLevel))
            {
                var config = RealmConfig.Get(realmLevel);
                m_Icon.SetActive(true);
                m_Icon.SetSprite(config.Img);
            }
            else
            {
                m_Icon.SetActive(false);
            }
        }
 
        void DisplayProperty()
        {
            var index = 0;
            Dictionary<int, int> propertyDict;
            if (model.TryGetRealmProperty(realmLevel, out propertyDict))
            {
                var keys = propertyDict.Keys;
                foreach (var property in keys)
                {
                    m_Properties[index].SetActive(true);
                    m_Properties[index].Display(property, propertyDict[property]);
                    index++;
                }
            }
            for (int i = index; i < m_Properties.Count; i++)
            {
                m_Properties[i].SetActive(false);
            }
 
        }
 
        void DisplayEquip()
        {
            var level = 0;
            if (model.IsUnlockEquipRealm(realmLevel, out level)
                && model.displayRealmLevel >= model.realmEquipDisplayLevel)
            {
                m_ContainerUnlockEquip.SetActive(true);
                var config = RealmConfig.Get(realmLevel);
                m_UnlockEquip.SetSprite(config.equipNameIcon);
            }
            else
            {
                m_ContainerUnlockEquip.SetActive(false);
            }
        }
 
        void DisplayReiki()
        {
            var config = RealmConfig.Get(realmLevel);
            if (config.AddFreePoint == 0)
            {
                m_ContainerReiki.SetActive(false);
                return;
            }
            m_ContainerReiki.SetActive(true);
 
            m_ReikiPoint.text = config.AddFreePoint.ToString();
 
            int addTime = onHookModel.GetAddMaxOnHookTime(realmLevel);
            m_OnHookMaxTime.text = addTime == 0 ? string.Empty : Language.Get("GameOnHook8", addTime);
        }
 
        void DisplaySkill()
        {
            var config = RealmConfig.Get(realmLevel);
            if (config.LearnSkillIDInfo.Length < 4)
            {
                //json 字符串 可能会配置{}
                m_ContainerSkill.SetActive(false);
                return;
            }
            m_ContainerSkill.SetActive(true);
            var json = JsonMapper.ToObject(config.LearnSkillIDInfo);
 
            var array = JsonMapper.ToObject<int[]>(json[PlayerDatas.Instance.baseData.Job.ToString()].ToJson());
            var skillID = array[0]; //约定规则只显示第一个,普攻相关有多个
 
            var skillConfig = SkillConfig.Get(skillID);
            m_SkillIcon.SetSprite(skillConfig.IconName);
            m_SkillName.text = skillConfig.SkillName;
 
            m_ViewDetail.SetListener(() => {
                SkillDetails.ShowSkillDetails(skillID, SkillDetails.SkillSourceType.PlayerSkill, skillConfig.FightPower);
            });
        }
 
 
        void CreatePropertyBehaviour()
        {
            Dictionary<int, int> propertyDict;
            var requireBehaCount = 0;
            if (model.TryGetRealmProperty(realmLevel, out propertyDict))
            {
                requireBehaCount = propertyDict.Count;
            }
            if (requireBehaCount > m_Properties.Count)
            {
                var start = m_Properties.Count;
                for (int i = start; i < requireBehaCount; i++)
                {
                    var clone = GameObject.Instantiate<PropertyBehaviour>(m_ClonePropertyBeha, Vector3.zero, Quaternion.identity);
                    clone.transform.SetParent(m_PropertyRoot);
                    clone.transform.localScale = Vector3.one;
                    clone.SetActive(false);
                    m_Properties.Add(clone);
                }
            }
        }
 
        private void OnEquipPreview()
        {
            RealmEquipPreviewWin.selectRealmLevel = realmLevel;
            WindowCenter.Instance.Open<RealmEquipPreviewWin>();
        }
    }
}