少年修仙传客户端代码仓库
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
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
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
//--------------------------------------------------------
//    [Author]:           第二世界
//    [  Date ]:           Monday, March 04, 2019
//--------------------------------------------------------
 
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
 
//成交记录
namespace vnxbqy.UI
{
 
    public class TransactionRecordWin : Window ,SecondWindowInterface
    {
        [SerializeField] ScrollerController m_ScrollerController;
        [SerializeField] ScrollerController m_ScrollerControllerType;
        [SerializeField] GameObject m_TypeTip;
        [SerializeField] Text m_TypeText;
        [SerializeField] Button m_TypeButon;
        [SerializeField] GameObject m_TextObj;
 
        AuctionModel model { get { return ModelCenter.Instance.GetModel<AuctionModel>(); } }
 
        List<string> itemGuids = new List<string>();
        
        int AuctionType = 0;
        int MaxCount = 0;
 
        #region Built-in
        public Button close { get; set; }
 
        protected override void BindController()
        {
            if (this is SecondWindowInterface)
            {
                var frame = this.GetComponentInChildren<SecondFrameLoader2>();
                frame.Create();
                close = frame.GetComponentInChildren<Button>();
            }
        }
 
        protected override void AddListeners()
        {
            m_ScrollerController.OnRefreshCell += OnRefreshGridCell;
            m_ScrollerControllerType.OnRefreshCell += OnRefreshGridCellType;
            m_ScrollerController.lockType = EnhanceLockType.KeepVertical;
            var count = FuncConfigConfig.Get("AuctionHouse").Numerical3;
            MaxCount = int.Parse(count);
 
            close.AddListener(() =>
            {
                CloseImmediately();
            });
            m_TypeButon.AddListener(() =>
            {
                if (!m_TypeTip.activeSelf)
                {
                    m_TypeTip.SetActive(true);
                }
            });
        }
 
        protected override void OnPreOpen()
        {
            AuctionType = 0;
            AuctionInquiry.Instance.SendQueryAuctionRecord(AuctionType);//查询拍卖记录
            if (m_TypeTip.activeSelf)
            {
                m_TypeTip.SetActive(false);
            }
            m_TypeText.text = GetTextName(AuctionType);
            OnCreateGridTypeCell(m_ScrollerControllerType);
            OnCreateGridCell(m_ScrollerController);
        }
 
        protected override void OnAfterOpen()
        {
            model.auctionRecordRefresh += PlayerAuctionRecordUpdate;
        }
 
        protected override void OnPreClose()
        {
            model.auctionRecordRefresh -= PlayerAuctionRecordUpdate;
        }
 
 
 
        protected override void OnAfterClose()
        {
        }
        #endregion
        private void PlayerAuctionRecordUpdate()
        {
            OnCreateGridCell(m_ScrollerController);
        }
        private void OnCreateGridCell(ScrollerController gridCtrl)
        {
            GetAuctionRecordList();
            if (itemGuids.Count > 0)
            {
                m_TextObj.SetActive(false);
            }
            else
            {
                m_TextObj.SetActive(true);
            }
            gridCtrl.Refresh();
            for (int i = 0; i < itemGuids.Count; i++)
            {
                if (i < MaxCount)
                {
                    gridCtrl.AddCell(ScrollerDataType.Header, i);
                }
            }
            gridCtrl.Restart();
        }
        private void OnRefreshGridCell(ScrollerDataType type, CellView cell)
        {
            int index = cell.index;
            var guid = itemGuids[index];
 
            AuctionItem item;
            if (!model.TryGetAuctionRecordItem(guid, out item))
            {
                return;
            }
 
            var itemConfig = ItemConfig.Get(item.itemId);
 
            ItemCell itemCell = cell.transform.Find("ItemCell1").GetComponent<ItemCell>();
            Text textName = cell.transform.Find("ItemName").GetComponent<Text>();
            RichText transactionStatusText = cell.transform.Find("TransactionStatusText").GetComponent<RichText>();
            Text timeText = cell.transform.Find("TimeText").GetComponent<Text>();
            ItemCellModel cellModel = new ItemCellModel(itemConfig.ID, true, (ulong)item.itemCount);
 
            GameObject SuccessfulBiddingObj = cell.transform.Find("SuccessfulBiddingObj").gameObject;//竞拍成功(竞拍成功)
            TextEx SuccessfulBiddingText = cell.transform.Find("SuccessfulBiddingObj/SuccessfulBiddingText").GetComponent<TextEx>();
            Text JadeMoney = cell.transform.Find("SuccessfulBiddingObj/JadeMoney").GetComponent<Text>();
 
            GameObject AuctionFailedObj = cell.transform.Find("AuctionFailedObj").gameObject;//竞拍失败
            Text JadeMoney_1 = cell.transform.Find("AuctionFailedObj/JadeMoney").GetComponent<Text>();
            switch (item.recordResult)
            {
                case 0://流拍
                    transactionStatusText.SetActive(true);
                    SuccessfulBiddingObj.SetActive(false);
                    AuctionFailedObj.SetActive(false);
                    transactionStatusText.text = Language.Get("PMH_11");
                    break;
                case 1://拍卖成交(竞拍成功)
                    SuccessfulBiddingObj.SetActive(true);
                    transactionStatusText.SetActive(false);
                    AuctionFailedObj.SetActive(false);
                    SuccessfulBiddingText.text = Language.Get("PMH_15");
                    JadeMoney.text = item.biddingPrice.ToString();
                    break;
                case 2://回收
                    transactionStatusText.SetActive(true);
                    SuccessfulBiddingObj.SetActive(false);
                    AuctionFailedObj.SetActive(false);
                    transactionStatusText.text = Language.Get("PMH_14");
                    break;
                case 3://竞价成功
                    SuccessfulBiddingObj.SetActive(true);
                    transactionStatusText.SetActive(false);
                    AuctionFailedObj.SetActive(false);
                    string strName = string.Empty;
                    SuccessfulBiddingText.text = Language.Get("PMH_13");
                    JadeMoney.text = item.biddingPrice.ToString();
                    break;
                case 4://竞价失败
                    AuctionFailedObj.SetActive(true);
                    SuccessfulBiddingObj.SetActive(false);
                    transactionStatusText.SetActive(false);
                    JadeMoney_1.text = item.biddingPrice.ToString();
                    break;
                case 5://仙盟流拍到全服
                    transactionStatusText.SetActive(true);
                    SuccessfulBiddingObj.SetActive(false);
                    AuctionFailedObj.SetActive(false);
                    transactionStatusText.text = Language.Get("PMH_12");
                    break;
                case 6://下架
                    transactionStatusText.SetActive(true);
                    SuccessfulBiddingObj.SetActive(false);
                    AuctionFailedObj.SetActive(false);
                    transactionStatusText.text = Language.Get("PMH_116");
                    JadeMoney.text = item.biddingPrice.ToString();
                    break;
            }
 
            itemCell.Init(cellModel);
            itemCell.button.SetListener(() =>
            {
                ItemTipUtility.Show(itemConfig.ID);
            });
            textName.text = UIHelper.GetItemName(itemConfig.ID, true);
            textName.color = UIHelper.GetUIColor(itemConfig.ItemColor, true);
            timeText.text = item.putAwayTime.ToString("dd-MM-yyyy HH:mm:ss");
        }
 
        private void OnCreateGridTypeCell(ScrollerController gridCtrl)
        {
 
            gridCtrl.Refresh();
            for (int i = 0; i < 3; i++)
            {
                gridCtrl.AddCell(ScrollerDataType.Header, i);
            }
            gridCtrl.Restart();
        }
        private void OnRefreshGridCellType(ScrollerDataType type, CellView cell)
        {
            int idnex = cell.index;
            Text textName = cell.transform.Find("Text").GetComponent<Text>();
            Button button = cell.GetComponent<Button>();
            textName.text = GetTextName(idnex);
            button.SetListener(() =>
            {
                if (idnex != AuctionType)
                {
                    AuctionType = idnex;
                    AuctionInquiry.Instance.SendQueryAuctionRecord(idnex);//查询拍卖记录
                    m_TypeTip.SetActive(false);
                    OnCreateGridCell(m_ScrollerController);
                    m_TypeText.text = GetTextName(AuctionType);
                }
            });
        }
 
        private string GetTextName(int index)
        {
            string str = string.Empty;
            switch (index)
            {
                case 0:
                    str = Language.Get("PMH_08");
                    break;
                case 1:
                    str = Language.Get("PMH_09");
                    break;
                case 2:
                    str = Language.Get("PMH_10");
                    break;
            }
            return str;
        }
 
        private void GetAuctionRecordList()
        {
            this.itemGuids.Clear();
            var itemGuids = model.GetAuctionRecords();
            foreach (var guid in itemGuids)
            {
                AuctionItem item;
                if (model.TryGetAuctionRecordItem(guid, out item))
                {
                    if (item.recordType == AuctionType)
                    {
                        this.itemGuids.Add(guid);
                    }
                }
 
            }
            this.itemGuids.Sort(Compare);
        }
 
        int Compare(string x, string y)
        {
            AuctionItem lhs;
            AuctionItem rhs;
            if (model.TryGetAuctionRecordItem(x, out lhs)
                && model.TryGetAuctionRecordItem(y, out rhs))
            {
                return -lhs.putAwayTime.CompareTo(rhs.putAwayTime);
            }
            return 1;
        }
    }
 
}