少年修仙传客户端代码仓库
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
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
//--------------------------------------------------------
//    [Author]:           第二世界
//    [  Date ]:           Monday, January 15, 2018
//--------------------------------------------------------
 
using System;
using System.Collections;
using System.Collections.Generic;
 
using UnityEngine;
using UnityEngine.UI;
//坐骑的弹框
namespace Snxxz.UI
{
 
    public class AutoTrainTipsWin : Window
    {
        #region Built-in
        [SerializeField] Button m_CloseBtn;//关闭
        [SerializeField] Button m_CancelBtn;//取消
        [SerializeField] Button m_ConfirmBtn;//确定
        [SerializeField] Button m_BtnReduce;//减
        [SerializeField] Button m_BtnPlus;//加
 
        [SerializeField] Button _DotText1Btn;//计算器按钮
        [SerializeField] Button _NumKeyBoardBGM;//计算机面板按钮
        [SerializeField] NumKeyBoard _NumKeyBoard;//计算机
 
        [SerializeField] Text NextToLvText;//需要驯养等级
        [SerializeField] Text NeedNumberText;//所需购买的颗数
        [SerializeField] Text m_NowLevelTxt;//当前等级
 
        private int horseID = 0;
        public static int _Lvnumber = 0;//标记需要升到所需的阶数
        public static int DomesticateNumber = 0;//驯养次数
        private MountWin moutwin = new MountWin();
        private bool isBool = true;
        public static bool IsFairy = false;
        List<HorseSkillClass> MountSkills = new List<HorseSkillClass>();
        MountModel m_MountModel;
        MountModel mountModel { get { return m_MountModel ?? (m_MountModel = ModelCenter.Instance.GetModel<MountModel>()); } }
        protected override void BindController()
        {
            moutwin = WindowCenter.Instance.Get<MountWin>();
        }
 
        protected override void AddListeners()
        {
            m_CloseBtn.AddListener(OnClickCloseButton);
            m_CancelBtn.AddListener(OnClickCancelButton);
            m_ConfirmBtn.AddListener(OnClickConfirmButton);
            m_BtnReduce.AddListener(OnClickReduceButton);
            m_BtnPlus.AddListener(OnClickPlusButton);
            _DotText1Btn.AddListener(OnClickDotText1);
            _NumKeyBoardBGM.AddListener(OnClickNumKeyBoardBGM);
           _NumKeyBoard.onValueChange.AddListener(OnClickNumKeyBoardValueChange);
            _NumKeyBoard.onConfirm.AddListener(onConfirm);
           
        }
 
        protected override void OnPreOpen()
        {
            IsFairy = false;
            _NumKeyBoardBGM.gameObject.SetActive(false);
            isBool = true;
            horseID = moutwin.signHorseID;
            m_NowLevelTxt.text = string.Format(Language.Get("Z1031"), mountModel._DicHorse[horseID].Lv);
            GetMountSkills(horseID);
            PropertyEntries(horseID);//默认自动选择      
            int GetLvNow = mountModel._DicHorse[horseID].Lv;
            int MaxLv = HorseConfig.Get(horseID).MaxLV;
            _NumKeyBoard.min = (uint)(GetLvNow + 1);
            _NumKeyBoard.max = (uint)MaxLv;
        }
 
        protected override void OnAfterOpen()
        {
        }
 
        protected override void OnPreClose()
        {
        }
 
        protected override void OnAfterClose()
        {
        }
        #endregion
 
        private void GetMountSkills(int MountID)//获取坐骑的技能
        {
            MountSkills.Clear();
            foreach (var key in mountModel.GetMountSkillAndItem.Keys)
            {
                if (mountModel.GetMountSkillAndItem[key].HorseID == MountID)
                {
                    MountSkills.Add(mountModel.GetMountSkillAndItem[key]);
                }
            }
        }
        private void PropertyEntries(int MountID)//默认自动选择
        {
            int NextMountLv = 0;
            int getLv = mountModel._DicHorse[MountID].Lv;
            HorseConfig horseconfig = HorseConfig.Get(MountID);
            bool IsBool = true;
            for (int i = 0; i < MountSkills.Count; i++)
            {
                if (MountSkills[i].HorseLV > getLv && IsBool)
                {
                    NextMountLv = MountSkills[i].HorseLV;
                    IsBool = false;
                }
            }
            if (IsBool)
            {
                NextMountLv = horseconfig.MaxLV;
            }
            _Lvnumber = NextMountLv;
            int NowHorseExp = HorseUpConfig.GetHorseIDAndLV(MountID, getLv).NeedExpTotal + mountModel._DicHorse[MountID].Exp;//当前等级的经验
            int NeedNumber = Mathf.CeilToInt((float)(HorseUpConfig.GetHorseIDAndLV(MountID, NextMountLv).NeedExpTotal - NowHorseExp) / 100);//所需要的颗数
            DomesticateNumber = NeedNumber;
            NeedNumberText.text = NeedNumber.ToString();
            NextToLvText.text = NextMountLv + Language.Get("Z1041");
        }
 
        private void SetMountSelectionInformation(int MountID, int LV)
        {
            int getLv = mountModel._DicHorse[MountID].Lv;
            int NowHorseExp = HorseUpConfig.GetHorseIDAndLV(MountID, getLv).NeedExpTotal + mountModel._DicHorse[MountID].Exp;//当前等级的经验
            int NeedNumber = Mathf.CeilToInt((float)(HorseUpConfig.GetHorseIDAndLV(MountID, LV).NeedExpTotal - NowHorseExp) / 100);//所需要的颗数
            DomesticateNumber = NeedNumber;
            NextToLvText.text = LV + Language.Get("Z1041");
            NeedNumberText.text = NeedNumber.ToString();
        }
 
        private void OnClickCloseButton()
        {
            Close();
        }
        private void OnClickCancelButton()
        {
            Close();
        }
        private void OnClickConfirmButton()//确定
        {
            int NeedFairyJade = DomesticateNumber* 10;
 
            int gold = (int)UIHelper.GetMoneyCnt(1);
            if (NeedFairyJade > 0 && gold >= NeedFairyJade)
            {
                IsFairy = true;
                moutwin.FairyJadeDomesticate();           
                Close();
            }
            else
            {
                if (VersionConfig.Get().isBanShu)
                {
                    SysNotifyMgr.Instance.ShowTip("GoldErr");
                    return;
                }
                WindowCenter.Instance.Open<RechargeTipWin>();
            }
 
        }
        private void OnClickReduceButton()//减
        {
            int getLvNow = mountModel._DicHorse[horseID].Lv;
            if (_Lvnumber - 1 < getLvNow + 1)
            {
                ScrollTip.ShowTip(Language.Get("BelowCultureLevel_Z"));
            }
            else
            {
                _Lvnumber -= 1;
                SetMountSelectionInformation(horseID, _Lvnumber);
            }
 
        }
        private void OnClickPlusButton()//加
        {
            int MaxLv = HorseConfig.Get(horseID).MaxLV;
            if (_Lvnumber + 1 <= MaxLv)
            {
                _Lvnumber += 1;
                SetMountSelectionInformation(horseID, _Lvnumber);
            }
            else
            {
                ScrollTip.ShowTip(Language.Get("MoreThanDomestication_Z"));
            }
        }
        private void OnClickDotText1()//中间点击
        {
            if (!_NumKeyBoardBGM.gameObject.activeSelf)
            {
                _NumKeyBoardBGM.gameObject.SetActive(true);
            }
        }
        private void OnClickNumKeyBoardBGM()//关闭面板
        {
            if (_NumKeyBoardBGM.gameObject.activeSelf)
            {
                _NumKeyBoardBGM.gameObject.SetActive(false);
            }
        }
 
        private void OnClickNumKeyBoardValueChange()
        {
            if (int.Parse(_NumKeyBoard.Value) > 999)
            {
                NextToLvText.text = 999 + Language.Get("Z1041");
            }
            else
            {
                NextToLvText.text = int.Parse(_NumKeyBoard.Value) + Language.Get("Z1041");
            }
 
           
        }
        private void NumKeyBoardValueChange()
        {
            int GetLvNow = mountModel._DicHorse[horseID].Lv;
            int MaxLv = HorseConfig.Get(horseID).MaxLV;
            if (int.Parse(_NumKeyBoard.Value) < GetLvNow + 1)
            {
                _Lvnumber = GetLvNow + 1;
                SetMountSelectionInformation(horseID, _Lvnumber);
                ScrollTip.ShowTip(Language.Get("LessThanTheDomesticated_Z"));
            }
            else if (int.Parse(_NumKeyBoard.Value) > MaxLv)
            {
                _Lvnumber = MaxLv;
                SetMountSelectionInformation(horseID, _Lvnumber);
                ScrollTip.ShowTip(Language.Get("MoreThanDomestication_Z"));
            }
            else if(int.Parse(_NumKeyBoard.Value)>= GetLvNow + 1 && int.Parse(_NumKeyBoard.Value)<= MaxLv)
            {
                _Lvnumber = int.Parse(_NumKeyBoard.Value);
                SetMountSelectionInformation(horseID, _Lvnumber);
            }
 
        }
        private void onConfirm(bool _bool)
        {
            if (_bool)
            {
                NumKeyBoardValueChange();
                _NumKeyBoardBGM.gameObject.SetActive(false);
            }
        }
    }
 
}