少年修仙传客户端代码仓库
client_Wu Xijin
2019-02-20 a87120c155c48fa45b20a97c1a58bdbeb77318b7
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
using Snxxz.UI;
using System;
using System.Collections;
using System.Collections.Generic;
 
using UnityEngine;
using UnityEngine.UI;
 
namespace Snxxz.UI
{
    public class GemEquipPlate : MonoBehaviour
    {
        [SerializeField] ItemCell m_ItemCell;
        [SerializeField] Image m_SelectImg;
        [SerializeField] Image m_EquipBg;
        [SerializeField] RedpointBehaviour m_Redpoint;
        [SerializeField] List<GameObject> m_GemHoles;
        [SerializeField] List<Image> m_Gems;
        [SerializeField] Text m_EquipNameTxt;
        [SerializeField] Text m_ContentTxt;
        [SerializeField] Text m_TipTxt;
        [SerializeField] Button m_EquipBtn;
 
        public int EquipPos { get; private set; }
 
        GemModel m_Model;
        GemModel model
        {
            get
            {
                return m_Model ?? (m_Model = ModelCenter.Instance.GetModel<GemModel>());
            }
        }
 
        VipModel m_VipModel;
        VipModel vipModel
        {
            get
            {
                return m_VipModel ?? (m_VipModel = ModelCenter.Instance.GetModel<VipModel>());
            }
        }
 
        PlayerPackModel _playerPack;
        PlayerPackModel playerPack
        {
            get { return _playerPack ?? (_playerPack = ModelCenter.Instance.GetModel<PlayerPackModel>()); }
        }
 
        private void Awake()
        {
            m_EquipBtn.onClick.AddListener(OnEquipPlateClick);
        }
 
        public void Refresh(int _pos)
        {
            EquipPos = _pos;
            ItemModel _itemModel = playerPack.GetItemModelByIndex(PackType.Equip,_pos);
            if (_itemModel != null)
            {
                ItemConfig cfg = ItemConfig.Get(_itemModel.itemId);
                m_EquipNameTxt.gameObject.SetActive(true);
                m_EquipNameTxt.text = UIHelper.AppendStringColor(cfg.ItemColor, cfg.ItemName, true);
                m_ItemCell.gameObject.SetActive(true);
                m_ItemCell.Init(_itemModel);
                m_ContentTxt.gameObject.SetActive(false);
                m_TipTxt.gameObject.SetActive(false);
            }
            else
            {
                m_ItemCell.gameObject.SetActive(false);
                for (int i = 0; i < m_GemHoles.Count; i++)
                {
                    m_GemHoles[i].gameObject.SetActive(false);
                }
                m_ContentTxt.gameObject.SetActive(true);
                var equipPartName = string.Empty;
                if (_pos - 1 < model.equipPartNames.Length)
                {
                    equipPartName = model.equipPartNames[_pos - 1];
                }
                m_ContentTxt.text = Language.Get("L1076", equipPartName);
                m_TipTxt.gameObject.SetActive(true);
                m_TipTxt.text = Language.Get("L1067");
                m_EquipNameTxt.gameObject.SetActive(false);
            }
            RefreshGem();
            m_Redpoint.redpointId = GemModel.GEM_REDPOINT * GemModel.REDPOINT_INTERVAL + _pos;
        }
 
        private static Queue<uint> m_GemIdQueue = new Queue<uint>();
        public void RefreshGem()
        {
            ItemModel _itemModel = playerPack.GetItemModelByIndex(PackType.Equip,EquipPos);
            if (_itemModel == null)
            {
                return;
            }
            ItemConfig cfg = ItemConfig.Get(_itemModel.itemId);
            int holeCnt = 0;
            m_GemIdQueue.Clear();
            uint[] stones = PlayerStoneData.Instance.GetStoneInfo(EquipPos);
            if (stones != null && stones.Length > 0)
            {
                for (int i = 0; i < 4; i++)
                {
                    if (stones[i] != 0)
                    {
                        m_GemIdQueue.Enqueue(stones[i]);
                    }
                }
            }
            for (int i = 0; i < 4; i++)
            {
                bool openHole = false;
                if (i < 3)
                {
                    if (cfg.LV >= model.gemOpenArray[i])
                    {
                        openHole = true;
                    }
                }
                else if (i == 3)
                {
                    if (PlayerDatas.Instance.baseData.VIPLv >= model.gemVipHoleLv && cfg.LV >= model.gemOpenArray[0])
                    {
                        openHole = true;
                    }
                }
                m_Gems[i].gameObject.SetActive(m_GemIdQueue.Count > 0);
                if (m_GemIdQueue.Count > 0)
                {
                    uint id = m_GemIdQueue.Dequeue();
                    ItemConfig itemCfg = ItemConfig.Get((int)id);
                    if (itemCfg.EffectValueA1 == 1)
                    {
                        m_Gems[i].SetSprite("Member_Online");
                    }
                    else if (itemCfg.EffectValueA1 == 2)
                    {
                        m_Gems[i].SetSprite("Member_Offline");
                    }
                }
                if (openHole)
                {
                    m_GemHoles[holeCnt].gameObject.SetActive(true);
                    holeCnt++;
                }
            }
            for (int i = holeCnt; i < 4; i++)
            {
                m_GemHoles[i].SetActive(false);
                m_Gems[i].gameObject.SetActive(false);
            }
        }
 
        public void SetSelect(bool _select)
        {
            m_SelectImg.gameObject.SetActive(_select);
        }
 
        private void OnEquipPlateClick()
        {
            model.UpdateEquipPlate(EquipPos);
        }
    }
}