少年修仙传客户端代码仓库
hch
2025-07-24 50e53441950268933694eeb5aad36147bbe1014d
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
using System;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
 
using vnxbqy.UI;
 
namespace vnxbqy.UI
{
    public class ExtendWin : Window
    {
        #region 成员变量
        private Text _number;
        private Button _extendBtn;
        private Button _closeBtn;
        private int _openCount;
        private PackType _packType;
        private ItemConfig _chinItemModel;
        private FuncConfigConfig _tagFuncModel;
        private ItemCell _itemCell = null;
        private int _needToolCount = 0;
        private int _haveCount = 0;
        #endregion
 
        ItemTipsModel _itemTipsModel;
        ItemTipsModel itemTipsModel
        {
            get
            {
                return _itemTipsModel ?? (_itemTipsModel = ModelCenter.Instance.GetModel<ItemTipsModel>());
            }
        }
 
        PackModel _playerPack;
        PackModel playerPack
        {
            get { return _playerPack ?? (_playerPack = ModelCenter.Instance.GetModel<PackModel>()); }
        }
 
        #region Built-in
        protected override void AddListeners()
        {
            _extendBtn.onClick.RemoveAllListeners();
            _closeBtn.onClick.RemoveAllListeners();
            _extendBtn.onClick.AddListener(OnClickExtendBtn);
            _closeBtn.onClick.AddListener(OnClickCloseBtn);
        }
 
        protected override void BindController()
        {
            _number = transform.Find("NumText").GetComponent<Text>();
            _extendBtn = transform.Find("Extendbtn").GetComponent<Button>();
            _closeBtn = transform.Find("Closebtn").GetComponent<Button>();
            _itemCell = transform.Find("ItemCell").GetComponent<ItemCell>();
        }
 
        protected override void OnAfterClose()
        {
            
        }
 
        protected override void OnAfterOpen()
        {
           
        }
 
        protected override void OnPreClose()
        {
          
        }
 
        protected override void OnPreOpen()
        {
            _tagFuncModel = FuncConfigConfig.Get("OpenBagItem");
            if(_tagFuncModel != null)
                _chinItemModel = ItemConfig.Get(_tagFuncModel.Numerical1);
 
            OpenExtendWin(itemTipsModel.OpenCount, itemTipsModel.Index, itemTipsModel.packType);
 
        }
        #endregion
 
 
        private void OpenExtendWin(int arg1, int arg2, PackType arg3)
        {
            InitPanel(arg1,arg2,arg3);
        }
 
        public void InitPanel(int openCount,int startlockIndex,PackType type)
        {
            if (_chinItemModel == null)
                return;
 
            _openCount = openCount;
            _packType = type;
            _number.text = openCount.ToString();
            //pdr ToDo
            ItemCellModel cellModel = new ItemCellModel(_chinItemModel.ID);
            _itemCell.Init(cellModel);
            _itemCell.button.RemoveAllListeners();
            _itemCell.button.onClick.AddListener(()=>
            {
                ItemTipUtility.Show(_chinItemModel.ID);
            });
            Text countText = _itemCell.transform.Find("Container_ItemCell/Txt_Count").GetComponent<Text>();
            countText.SetActive(true);
            int i = 0;
            int needToolCount = 0;
            for (i = 0; i < openCount; i++)
            {
                int index = startlockIndex - (openCount - 1 - i);
                Equation.Instance.Clear();
                Equation.Instance.AddKeyValue("index", index);
                int needTool = Equation.Instance.Eval<int>(_tagFuncModel.Numerical2);
                needToolCount += needTool;
            }
 
            _haveCount = playerPack.GetItemCountByID(PackType.Item,_chinItemModel.ID);
            
            if(_haveCount >= needToolCount)
            {
                string s = _haveCount + "/" + needToolCount;
                countText.text = UIHelper.AppendColor(TextColType.White, s);
            }
            else
            {
                string s = UIHelper.AppendColor(TextColType.Red, _haveCount.ToString())  + "/" + UIHelper.AppendColor(TextColType.White, needToolCount.ToString());
                countText.text = s;
            }
            _needToolCount = needToolCount;
           
        }
 
        private void OnClickExtendBtn()
        {
            if(_haveCount >= _needToolCount)
            {
                C0741_tagCOpenPackCount openGrid = new C0741_tagCOpenPackCount();
                openGrid.PackType = (byte)_packType;
                openGrid.Count = (byte)_openCount;
                GameNetSystem.Instance.SendInfo(openGrid);
                OnClickCloseBtn();
            }
            else
            {
                int needMoney = (_needToolCount - _haveCount) * int.Parse(_tagFuncModel.Numerical3);
                ConfirmCancel.ShowPopConfirm(Language.Get("Mail101"),Language.Get("Extend101").Replace("{0}", needMoney.ToString()),
                    (bool isOk)=> {
                        if(isOk)
                        {
                            if(PlayerDatas.Instance.baseData.bindDiamond >= needMoney)
                            {
                                C0741_tagCOpenPackCount openGrid = new C0741_tagCOpenPackCount();
                                openGrid.PackType = (byte)_packType;
                                openGrid.Count = (byte)_openCount;
                                GameNetSystem.Instance.SendInfo(openGrid);
                            }
                            else
                            {
                                if (VersionConfig.Get().isBanShu)
                                {
                                    SysNotifyMgr.Instance.ShowTip("GoldErr");
                                    return;
                                }
                                //WindowCenter.Instance.Open<RechargeTipWin>();
                                SysNotifyMgr.Instance.ShowTip("LackMoney", 2);
                            }
                          
                        }
                        OnClickCloseBtn();
                    }
                    );
            }
          
          
        }
        private void OnClickCloseBtn()
        {
            WindowCenter.Instance.Close<ExtendWin>();
        }
    }
 
}