少年修仙传客户端代码仓库
hch
2025-06-12 204ef05a831c9484e2abc561d27ecbff7c797453
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
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
using System.Collections.Generic;
using System.Dynamic;
using System.Linq;
using UnityEngine;
namespace vnxbqy.UI
{
    //福地-寻觅
    public class BlessedLandSeekWin : Window
    {
        [SerializeField] ScrollerController itemScroller;
        [SerializeField] TextEx txtTime;
        [SerializeField] ButtonEx btnClose;
        [SerializeField] ButtonEx btnRefresh;
        [SerializeField] ImageEx imgRefresh;
        BlessedLandModel blessedLandModel { get { return ModelCenter.Instance.GetModel<BlessedLandModel>(); } }
 
        protected override void BindController()
        {
 
        }
 
        protected override void AddListeners()
        {
            btnClose.SetListener(() =>
            {
                WindowCenter.Instance.Close<BlessedLandSeekWin>();
            });
 
            btnRefresh.SetListener(() =>
            {
                bool isLimit = blessedLandModel.TryGetRefreshTypeDailyLimitValue(2, out int maxLimit);
                if (isLimit)
                {
                    if (blessedLandModel.RefreshCountRob >= maxLimit)
                    {
                        SysNotifyMgr.Instance.ShowTip("XBTodayMax");
                        return;
                    }
                }
                //在冷却时间中
                if (blessedLandModel.GetCoolDownEndTime(0) > 0)
                    return;
 
                blessedLandModel.SendCB031Pack(2);
                blessedLandModel.lastSurroundRefreshTime = TimeUtility.AllSeconds;
                blessedLandModel.SetTime(0);
                blessedLandModel.SaveAllTime();
            });
        }
 
        protected override void OnPreOpen()
        {
            itemScroller.OnRefreshCell += OnItemCellScrollerRefreshCell;
            GlobalTimeEvent.Instance.secondEvent += OnSecondEvent;
            blessedLandModel.UpdateFellowAndSurroundAreaData += OnUpdateFellowAndSurroundAreaData;
            blessedLandModel.UpdateFindAreaData += OnUpdateFindAreaData;
            DTC0102_tagCDBPlayer.beforePlayerDataInitializeEvent += OnBeforePlayerDataInitialize;
            Display();
        }
 
        protected override void OnAfterClose()
        {
 
        }
 
        protected override void OnAfterOpen()
        {
            CreateItemScroller();
        }
 
        protected override void OnPreClose()
        {
            itemScroller.OnRefreshCell -= OnItemCellScrollerRefreshCell;
            blessedLandModel.UpdateFellowAndSurroundAreaData -= OnUpdateFellowAndSurroundAreaData;
            GlobalTimeEvent.Instance.secondEvent -= OnSecondEvent;
            blessedLandModel.UpdateFindAreaData -= OnUpdateFindAreaData;
            DTC0102_tagCDBPlayer.beforePlayerDataInitializeEvent -= OnBeforePlayerDataInitialize;
        }
 
        private void OnSecondEvent()
        {
            Display();
            if (blessedLandModel.GetCoolDownEndTime(0) > 0)
            {
                txtTime.text = TimeUtility.SecondsToDHMS(blessedLandModel.GetCoolDownEndTime(0));
            }
        }
 
        void Display()
        {
            txtTime.SetActive(blessedLandModel.GetCoolDownEndTime(0) > 0);
            imgRefresh.sprite = blessedLandModel.GetCoolDownEndTime(0) == 0 ? UILoader.LoadSprite("BlessedLand03") : UILoader.LoadSprite("BlessedLand04");
        }
 
        private void OnUpdateFindAreaData()
        {
            WindowJumpMgr.Instance.WindowJumpToEx("BlessedLandOtherWin");
        }
 
 
        private void OnUpdateFellowAndSurroundAreaData()
        {
            CreateItemScroller();
        }
 
        private void OnItemCellScrollerRefreshCell(ScrollerDataType type, CellView cell)
        {
            if (type == ScrollerDataType.Header)
            {
                var _cell = cell as BlessedLandSeekHeadCell;
                _cell.Display(_cell.index);
            }
            else
            {
                var _cell = cell as BlessedLandSeekNormalCell;
                _cell.Display(_cell.index, cell);
            }
        }
 
        void CreateItemScroller()
        {
            itemScroller.Refresh();
 
            int combinedValue = 0;
            itemScroller.AddCell(ScrollerDataType.Header, combinedValue);
            if (blessedLandModel.typeToPlayerIDs.ContainsKey(3))
            {
                List<uint> keyList = blessedLandModel.typeToPlayerIDs[3];
                int minIndex = blessedLandModel.surroundCount;
 
                Dictionary<int, int> dict = blessedLandModel.realmUnlockPlayerCountDict;
                var list = dict.Keys.ToList();
                list.Sort();
                int maxNum = list[list.Count - 1];
 
                for (int i = 0; i < maxNum; i++)
                {
                    CellInfo cellInfo = new CellInfo();
                    if (i< keyList.Count)
                    {
                        combinedValue = (int)keyList[i] * 10 + 3;
                        if (i < minIndex)
                        {
                            cellInfo.infoInt1 = -1;
                        }
                        else
                        {
                            cellInfo.infoInt1 = i - minIndex;
                        }
                    }
                    else
                    {
                        cellInfo.infoInt1 = i - minIndex;
                    }
                    itemScroller.AddCell(ScrollerDataType.Normal, combinedValue, cellInfo);
                }
            }
 
            combinedValue = 1;
            itemScroller.AddCell(ScrollerDataType.Header, combinedValue);
            if (blessedLandModel.typeToPlayerIDs.ContainsKey(2))
            {
                List<uint> keyList = blessedLandModel.typeToPlayerIDs[2];
                for (int i = 0; i < keyList.Count; i++)
                {
                    combinedValue = (int)keyList[i] * 10 + 2;
                    CellInfo cellInfo = new CellInfo();
                    cellInfo.infoInt1 = -1;
                    itemScroller.AddCell(ScrollerDataType.Normal, combinedValue, cellInfo);
                }
            }
 
            itemScroller.Restart();
        }
 
        public void OnBeforePlayerDataInitialize()
        {
            if (WindowCenter.Instance.IsOpen<BlessedLandSeekWin>())
            {
                WindowJumpMgr.Instance.ClearJumpData();
                WindowCenter.Instance.CloseAll();
            }
        }
 
    }
}