少年修仙传客户端代码仓库
client_Wu Xijin
2019-06-13 033958214c0b16d7e7b93cc821b018c295251867
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
using System;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
 
 
namespace Snxxz.UI
{
    public class CrossServerOneVsOneHonorStoreWin : Window
    {
        [SerializeField] ScrollerController shopCtrl;
 
        StoreModel _storeModel;
        StoreModel m_storeModel
        {
            get { return _storeModel ?? (_storeModel = ModelCenter.Instance.GetModel<StoreModel>()); }
        }
 
        List<StoreModel.StoreData> shoplist;
        int SingleLineCnt = 2;
 
        protected override void BindController()
        {
            shopCtrl.OnRefreshCell += RefreshShopCell;
            shopCtrl.lockType = EnhanceLockType.KeepVertical;
        }
 
        protected override void AddListeners()
        {
            
        }
 
        protected override void OnPreOpen()
        {
            m_storeModel.RefreshBuyShopLimitEvent += CreateShopCell;
            m_storeModel.storeFuncType = StoreFunc.CrossOneVsOneHonor;
            CreateShopCell();
        }
        protected override void OnAfterOpen()
        {
         
        }
 
        protected override void OnPreClose()
        {
            m_storeModel.RefreshBuyShopLimitEvent -= CreateShopCell;
        }
        protected override void OnAfterClose()
        {
 
        }
 
        private void CreateShopCell()
        {
         
            shoplist = m_storeModel.TryGetStoreDatas(m_storeModel.storeFuncType);
            if(shoplist == null)
            {
                DebugEx.Log("跨服商店数据为空");
                return;
            }
 
            shopCtrl.Refresh();
            if (shoplist.Count > 0)
            {
                int i = 0;
                int remain = shoplist.Count % SingleLineCnt;
                int line = (int)shoplist.Count / SingleLineCnt;
                if (remain > 0)
                {
                    line += 1;
                }
 
                for (i = 0; i < line; i++)
                {
                    shopCtrl.AddCell(ScrollerDataType.Header, i);
                }
            }
            shopCtrl.Restart();
 
            shopCtrl.JumpIndex(0);
        }
 
        private void RefreshShopCell(ScrollerDataType type, CellView cell)
        {
            int length = cell.transform.childCount;
            for(int i = 0; i < length;i++)
            {
                int cellCount = length * cell.index + (i + 1);
                CrossServerOneVsOneHonorShopCell shopCell = cell.transform.GetChild(i).GetComponent<CrossServerOneVsOneHonorShopCell>();
                if(shoplist.Count >= cellCount)
                {
                    shopCell.gameObject.SetActive(true);
                    shopCell.SetDisplay(shoplist[cellCount-1].storeConfig);
                }
                else
                {
                    shopCell.gameObject.SetActive(false);
                }
            }
        }
 
    }
}