少年修仙传客户端代码仓库
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
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
 
namespace vnxbqy.UI
{
    
    public class EquipGemSelectBehaviour : CellView
    {
        [SerializeField] Transform m_ContainerEquip;
        [SerializeField] Transform m_ContainerUnEquip;
        [SerializeField] Text m_EquipPlaceName;
        [SerializeField] Transform m_ContainerSelect;
        [SerializeField] ItemCell m_Item;
        [SerializeField] Text m_EquipStar;
        [SerializeField] Text m_ItemName;
        [SerializeField] TinyGem[] m_TinyGems;
        [SerializeField] Button m_Select;
        [SerializeField] RedpointBehaviour m_Redpoint;
 
        EquipGemModel model { get { return ModelCenter.Instance.GetModel<EquipGemModel>(); } }
        EquipModel equipModel { get { return ModelCenter.Instance.GetModel<EquipModel>(); } }
        EquipStarModel equipStarModel { get { return ModelCenter.Instance.GetModel<EquipStarModel>(); } }
        PackModel packModel { get { return ModelCenter.Instance.GetModel<PackModel>(); } }
 
        int equipLevel = 0;
        int equipPlace = 0;
        string equipGuid = string.Empty;
 
        public void Display(int level, int place)
        {
            this.equipLevel = level;
            this.equipPlace = place;
 
            var equipSet = equipModel.GetEquipSet(equipLevel);
            equipGuid = equipSet.GetEquip(equipPlace);
 
            var equiped = !string.IsNullOrEmpty(equipGuid);
            m_ContainerEquip.SetActive(equiped);
            m_ContainerUnEquip.SetActive(!equiped);
 
            m_Select.SetListener(() => { model.selectEquipPlace = equipPlace; });
 
            if (equiped)
            {
                DisplayBase();
                DisplayGems();
 
                EquipGemRedpoint equipGemRedpoint;
                if (model.TryGetRedpoint(level, place, out equipGemRedpoint))
                {
                    m_Redpoint.redpointId = equipGemRedpoint.repoint.id;
                }
            }
            else
            {
                m_Redpoint.redpointId = 0;
                DisplayUnEquip();
            }
 
            m_ContainerSelect.SetActive(model.selectEquipPlace == equipPlace);
        }
 
        void DisplayBase()
        {
            var item = packModel.GetItemByGuid(equipGuid);
            if (item != null)
            {
                m_Item.Init(item);
                m_Item.button.enabled = false;
                m_ItemName.text = item.config.ItemName;
                m_ItemName.color = UIHelper.GetUIColor(item.config.ItemColor, true);
 
                var maxStar = EquipStarModel.GetMaxStarLevel(item.config.ItemColor, item.config.LV);
                var starLevel = Mathf.Min(maxStar, equipStarModel.GetStarLevel(new Int2(equipLevel, equipPlace)));
                m_EquipStar.text = starLevel == 0 ? string.Empty : Language.Get("EquipStarLevel", starLevel);
            }
        }
 
        void DisplayGems()
        {
            int[] equipGems = null;
            model.TryGetEquipGems(equipLevel, equipPlace, out equipGems);
            for (int i = 0; i < m_TinyGems.Length; i++)
            {
                bool isOpen = model.IsEquipGemHoleOpen(equipLevel, equipPlace, i);
                m_TinyGems[i].SetActive(isOpen);
                if (isOpen)
                {
                    var id = (equipGems != null && i < equipGems.Length) ? equipGems[i] : 0;
                    m_TinyGems[i].Set(id);
                }
            }
        }
 
        void DisplayUnEquip()
        {
            if (GeneralDefine.equipPlaceNameDict.ContainsKey(equipPlace))
            {
                m_EquipPlaceName.text = Language.Get("L1076", GeneralDefine.equipPlaceNameDict[equipPlace]);
            }
        }
    }
}