少年修仙传客户端代码仓库
client_Wu Xijin
2019-02-25 a7c531aa353dae5b40b3c47f37211666ed0250a6
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
//--------------------------------------------------------
//    [Author]:           第二世界
//    [  Date ]:           Friday, September 15, 2017
//--------------------------------------------------------
 
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
 
//口粮兑换
namespace Snxxz.UI
{
 
    public class ConvertItemTipsWin : Window
    {
        public Image _EquipBG;//背景图
        public Image _ItemIcon;//图标
        public Text _TitleText;//物品名称
        public Text _TextContent;//可提升的数值
        public Text _TheIntegral;//所需的兑换积分
        public Text _DotText1;//兑换数量
        public Button _AddsButton1;//增加按钮
        public Button _MinusButton1;//减少按钮
        public Button _ConvertBtn;//兑换按钮
        public Button _CloseBtn;//关闭按钮
        public Button _DotText1Btn;//计算器按钮
        public Button _NumKeyBoardBGM;//计算机面板按钮
        public NumKeyBoard _NumKeyBoard;//计算机
        private int _TreasureIntegral = 0;//用于获取宝库积分
        private int _CurrentNumber = 1;//获取当前数量
 
        private int _NumberID = 0, _Number = 0, _Integral = 0, _BiggestLimit = 0, _ExperienceAdd = 0;//获取物品ID,数量,所需积分,做大上限,经验的增加
        FairyAuTreasureModel m_PlayerFairyAuTreasureData;
        FairyAuTreasureModel playerFairyAuTreasureData { get { return m_PlayerFairyAuTreasureData ?? (m_PlayerFairyAuTreasureData = ModelCenter.Instance.GetModel<FairyAuTreasureModel>()); } }
 
        #region Built-in
        protected override void BindController()
        {
            FuncConfigConfig _PetFoodExchange = FuncConfigConfig.Get("PetFoodExchange");
            _NumberID = int.Parse(_PetFoodExchange.Numerical1);
            _TitleText.text = ItemConfig.Get(_PetFoodExchange.Numerical1).ItemName;
            _ExperienceAdd = ItemConfig.Get(_PetFoodExchange.Numerical1).EffectValueA1;
            _Number = int.Parse(_PetFoodExchange.Numerical2);
            _Integral = int.Parse(_PetFoodExchange.Numerical3);
            _BiggestLimit = ItemConfig.Get(_PetFoodExchange.Numerical1).PackCount;
            _EquipBG.SetItemBackGround(ItemConfig.Get(_PetFoodExchange.Numerical1).ItemColor);
            _TextContent.text = ItemConfig.Get(_NumberID).Description;
            _ItemIcon.SetSprite(ItemConfig.Get(_NumberID).IconKey);
        }
 
        protected override void AddListeners()
        {
 
            _AddsButton1.onClick.AddListener(AddsButton);
            _MinusButton1.onClick.AddListener(MinusButton);
 
            _ConvertBtn.onClick.AddListener(ConvertButton);
            _CloseBtn.onClick.AddListener(CloseButton);
            _DotText1Btn.AddListener(DotText1Button);
            _NumKeyBoardBGM.AddListener(NumKeyBoardBGMButton);
            _NumKeyBoard.onValueChange.AddListener(NumKeyBoardValueChange);
            _NumKeyBoard.onConfirm.AddListener(onConfirm);
 
        }
 
        protected override void OnPreOpen()
        {
            _NumKeyBoardBGM.gameObject.SetActive(false);
            _TreasureIntegral = playerFairyAuTreasureData._FairyAuIntegral;
            _DotText1.text = "1";
            _CurrentNumber = 1;
            _TheIntegral.text = (_CurrentNumber * _Integral).ToString();
            if (_TreasureIntegral >= _CurrentNumber * _Integral)
            {
                _TheIntegral.color = new Color(255,239,71);
            }
            else
            {
                _TheIntegral.color = UIHelper.GetUIColor(5, false);
            }
            _DotText1.text = _CurrentNumber.ToString();
 
        }
 
        protected override void OnAfterOpen()
        {
        }
 
        protected override void OnPreClose()
        {
        }
 
        protected override void OnAfterClose()
        {
        }
 
 
 
        void AddsButton()//增加按钮
        {
            if (_CurrentNumber >= _BiggestLimit)
                return;
            _CurrentNumber += 1 * _Number;
            if (_TreasureIntegral >= _CurrentNumber * _Integral)
            {
                _TheIntegral.color = new Color(255, 239, 71);
            }
            else
            {
                _TheIntegral.color = UIHelper.GetUIColor(5, false);
            }
            _DotText1.text = _CurrentNumber.ToString();
            _TheIntegral.text = (_CurrentNumber * _Integral).ToString();
        }
 
        void MinusButton()//减少按钮
        {
            if (_CurrentNumber <= 1)
                return;
            _CurrentNumber -= 1 * _Number;
            if (_TreasureIntegral >= _CurrentNumber * _Integral)
            {
                _TheIntegral.color = new Color(255, 239, 71);
            }
            else
            {
                _TheIntegral.color = UIHelper.GetUIColor(5, false);
            }
            _DotText1.text = _CurrentNumber.ToString();
            _TheIntegral.text = (_CurrentNumber * _Integral).ToString();
        }
 
        void ConvertButton()//兑换按钮
        {
            var playerPackModel = ModelCenter.Instance.GetModel<PackModel>();
            if (playerPackModel.GetEmptyGridCount(PackType.Item) < 1)
            {
                SysNotifyMgr.Instance.ShowTip("GeRen_chenxin_998371");
                Close();
                return;
            }
 
            if (_TreasureIntegral >= _CurrentNumber * _Integral)
            {
                CA610_tagCMFamilyStoreExchange _CA610 = new CA610_tagCMFamilyStoreExchange();
                _CA610.StoreItemIndex = 0;
                _CA610.ItemID = (uint)_NumberID;
                _CA610.ExcangeCount = (ushort)_CurrentNumber;
                GameNetSystem.Instance.SendInfo(_CA610);
                DebugEx.Log("兑换成功");
                Close();
            }
            else
            {
                ScrollTip.ShowTip(Language.Get("Z1058"));
                Close();
            }
        }
 
        void DotText1Button()//就算器按钮弹出按钮
        {
            _NumKeyBoardBGM.gameObject.SetActive(true);
 
        }
 
        void CloseButton()//关闭按钮
        {
            Close();
        }
 
        void NumKeyBoardValueChange()
        {
            _CurrentNumber = int.Parse(_NumKeyBoard.Value);
            if (_TreasureIntegral >= _CurrentNumber * _Integral)
            {
                _TheIntegral.color = new Color(255, 239, 71);
            }
            else
            {
                _TheIntegral.color = UIHelper.GetUIColor(5, false);
            }
            _DotText1.text = _CurrentNumber.ToString();
            _TheIntegral.text = (_CurrentNumber * _Integral).ToString();
        }
        void NumKeyBoardBGMButton()
        {
            _NumKeyBoardBGM.gameObject.SetActive(false);
 
        }
 
        void onConfirm(bool _bool)
        {
            if (_bool)
                _NumKeyBoardBGM.gameObject.SetActive(false);
        }
 
        #endregion
 
    }
 
}