少年修仙传客户端代码仓库
client_Wu Xijin
2019-02-13 c7f64d977c4e2884d5411a5a2d0f37b6afa52963
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
using Snxxz.UI;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using System;
 
 
namespace EnhancedUI.EnhancedScroller
{
    public class RuneBreakCell : ScrollerUI
    {
        [SerializeField] List<RectTransform> m_Runes;
        [SerializeField] List<Button> m_RuneBtns;
        [SerializeField] List<Image> m_RuneIcons;
        [SerializeField] List<Text> m_RuneNameTxts;
        [SerializeField] List<Text> m_RuneAttrTxts;
        [SerializeField] List<Image> m_RuneSelects;
 
        RuneModel m_Model;
        RuneModel model
        {
            get
            {
                return m_Model ?? (m_Model = ModelCenter.Instance.GetModel<RuneModel>());
            }
        }
        public override void Refresh(CellView cell)
        {
            for (int i = 0; i < 4; i++)
            {
                int index = cell.index * 4 + i;
                int _row = i;
                if (index >= model.runeBreakList.Count)
                {
                    m_Runes[i].gameObject.SetActive(false);
                    continue;
                }
                else
                {
                    m_Runes[i].gameObject.SetActive(true);
                }
                RuneData data = model.runeBreakList[index];
                m_RuneBtns[i].onClick.RemoveAllListeners();
                m_RuneBtns[i].onClick.AddListener(() =>
                {
                    OnClickRuneBreakItem(index, _row);
                });
                ItemConfig _itemCfg = ItemConfig.Get(data.id);
                if (_itemCfg == null)
                {
                    DebugEx.LogError("不存在的物品id" + data.id);
                    return;
                }
                if (_itemCfg.Type == RuneModel.RUNE_TYPE)
                {
                    m_RuneNameTxts[i].text =StringUtility.Contact(_itemCfg.ItemName," lv.",data.lv);
                    m_RuneNameTxts[i].color = UIHelper.GetUIColor(_itemCfg.ItemColor, true);
                    m_RuneAttrTxts[i].text = model.GetRuneAttrStr(data.id, data.lv);
                }
                else if (_itemCfg.Type == RuneModel.RUNE_CREAMTYPE)
                {
                    m_RuneNameTxts[i].text = _itemCfg.ItemName;
                    m_RuneNameTxts[i].color = UIHelper.GetUIColor(_itemCfg.ItemColor, true);
                    m_RuneAttrTxts[i].text = Language.Get("L1079", _itemCfg.EffectValueA1);
                }
                m_RuneIcons[i].SetSprite(_itemCfg.IconKey);
                if (model.runeBreakEnableDict.ContainsKey(index) && model.runeBreakEnableDict[index])
                {
                    if (!model.runeBreakRects.Contains(m_Runes[i]))
                    {
                        model.runeBreakRects.Add(m_Runes[i]);
                    }
                    m_RuneSelects[i].gameObject.SetActive(true);
                }
                else
                {
                    if (model.runeBreakRects.Contains(m_Runes[i]))
                    {
                        model.runeBreakRects.Remove(m_Runes[i]);
                    }
                    m_RuneSelects[i].gameObject.SetActive(false);
                }
            }
        }
 
        private void OnClickRuneBreakItem(int _index,int _row)
        {
            model.runeBreakEnableDict[_index] = !model.runeBreakEnableDict[_index];
            RuneData data = model.runeBreakList[_index];
            ItemConfig item = ItemConfig.Get(data.id);
            if (model.runeBreakEnableDict[_index])
            {
                if (!model.runeBreakRects.Contains(m_Runes[_row]))
                {
                    model.runeBreakRects.Add(m_Runes[_row]);
                }
                m_RuneSelects[_row].gameObject.SetActive(true);
            }
            else
            {
                if (model.runeBreakRects.Contains(m_Runes[_row]))
                {
                    model.runeBreakRects.Remove(m_Runes[_row]);
                }
                m_RuneSelects[_row].gameObject.SetActive(false);
            }
            model.UpdateBreakRune();
        }
    }
}