少年修仙传客户端代码仓库
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
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using UnityEngine;
using UnityEngine.UI;
 
namespace vnxbqy.UI
{
    
    public class EquipGemHoleBehaviour : MonoBehaviour
    {
        [SerializeField] Transform m_ContainerUnOpen;
        [SerializeField] Transform m_ContainerOpened;
        [SerializeField] Transform m_ContainerInlay;
        [SerializeField] Transform m_ContainerUnInlay;
        [SerializeField] Image m_ItemBackground;
        [SerializeField] Image m_ItemIcon;
        [SerializeField] Text m_ItemName;
        [SerializeField] Image m_Bind;
        [SerializeField] Text m_OpenCondition;
        [SerializeField] PropertyBehaviour[] m_Propertys;
        [SerializeField] Text m_GemType;
        [SerializeField] UIEffect m_Mosaic;
        [SerializeField] Button m_Inlaid;
        [SerializeField] RedpointBehaviour m_Redpoint;
        [SerializeField] Image m_SelectImg;
 
        EquipGemModel model { get { return ModelCenter.Instance.GetModel<EquipGemModel>(); } }
        EquipModel equipModel { get { return ModelCenter.Instance.GetModel<EquipModel>(); } }
 
        public void DisplayEquipGem(int level, int place, int hole)
        {
            var isOpen = model.IsEquipGemHoleOpen(level, place, hole);
 
            var equipGuid = equipModel.GetEquip( new Int2(level, place));
            isOpen = string.IsNullOrEmpty(equipGuid) ? false : isOpen;
 
            m_ContainerOpened.SetActive(isOpen);
            m_ContainerUnOpen.SetActive(!isOpen);
 
            m_Inlaid.RemoveAllListeners();
 
            if (!isOpen)
            {
                DisplayOpenCondition(hole);
                m_Redpoint.redpointId = 0;
            }
            m_SelectImg.SetActive(hole == model.SelectHoleIndex);
 
            if (isOpen)
            {
                m_Inlaid.AddListener(() =>
                {
                    Inlay(level, place, hole);
                });
 
                bool inlay = false;
                int[] equipGems = null;
                if (model.TryGetEquipGems(level, place, out equipGems))
                {
                    inlay = hole < equipGems.Length && equipGems[hole] != 0;
                }
 
                if (inlay)
                {
                    DisplayGemBase(equipGems[hole]);
                    DisplayGemProperty(equipGems[hole]);
                }
                else
                {
                    DisplayGemType(place);
                }
 
                m_ContainerInlay.SetActive(inlay);
                m_ContainerUnInlay.SetActive(!inlay);
 
                EquipGemRedpoint equipGemRedpoint;
                if (model.TryGetRedpoint(level, place, out equipGemRedpoint))
                {
                    var holeRedpoint = equipGemRedpoint.GetHoleRedpoint(hole);
                    m_Redpoint.redpointId = holeRedpoint.id;
                }
            }
        }
 
        void DisplayGemBase(int equipGem)
        {
            var config = ItemConfig.Get(equipGem);
            m_ItemBackground.SetItemBackGround(config.ItemColor, config.QualityEchoType);
            m_ItemIcon.SetSprite(config.IconKey);
            m_ItemName.text = config.ItemName;
            m_Bind.SetActive(false);
        }
 
        void DisplayOpenCondition(int hole)
        {
            GemHoleCondition condition;
            if (model.TryGetGemHoleCondition(hole, out condition))
            {
                if (condition.vipLevel != 0)
                {
                    m_OpenCondition.text = Language.Get("GemHole04Unlock", condition.vipLevel);
                }
                else
                {
                    m_OpenCondition.text = Language.Get("L1075", condition.equipStar);
                }
            }
        }
 
        public void DisplayGemProperty(int equipGem)
        {
            foreach (var gem in m_Propertys)
            {
                gem.SetActive(false);
            }
            //EquipGemWin.DisplayProperty(equipGem, m_Propertys);
        }
 
        public void DisplayGemType(int place)
        {
            List<int> gemTypes = null;
            var sb = new StringBuilder();
            if (model.TryGetGemTypes(place, out gemTypes))
            {
                foreach (var type in gemTypes)
                {
                    GemType gemType;
                    if (model.TryGetGemType(type, out gemType))
                    {
                        sb.Append(gemType.description);
                        sb.Append("\n");
                    }
                }
            }
            m_GemType.text = sb.ToString();
        }
 
        public void DisplayLevelUp(bool show)
        {
            if (show)
            {
                m_Mosaic.Play();
            }
            else
            {
                m_Mosaic.StopImediatly();
            }
        }
 
        private void Inlay(int level, int place, int hole)
        {
            bool inlay = false;
            int[] equipGems = null;
            if (model.TryGetEquipGems(level, place, out equipGems))
            {
                inlay = hole < equipGems.Length && equipGems[hole] != 0;
            }
            if (!inlay)
            {
                EquipGemSelectWin.equipHole = hole;
                EquipGemSelectWin.equipLevel = level;
                EquipGemSelectWin.equipPlace = place;
                WindowCenter.Instance.Open<EquipGemSelectWin>();
            }
            model.SelectHoleIndex = hole;
        }
    }
}