少年修仙传客户端代码仓库
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
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
//--------------------------------------------------------
//    [Author]:           第二世界
//    [  Date ]:           Saturday, September 02, 2017
//--------------------------------------------------------
 
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using LitJson;
 
namespace vnxbqy.UI
{
 
    public class LoginWin : Window
    {
        public static bool firstOpenEnd { get; private set; }
 
        private string m_ServerIP = "mobile.173on.com";
        private int m_Port = 9090;
        private int m_GamePort = 19006;
 
        [SerializeField] Image m_Logo;
        [SerializeField] UIAlphaTween m_AlphaTween;
        [SerializeField] RectTransform m_WaitServerList;
        [SerializeField] RectTransform m_ContainerEnterGame;
        [SerializeField] RectTransform m_ContainerAccount;
        [SerializeField] Image m_ServerState;
        [SerializeField] Text m_ServerStateDescription;
        [SerializeField] Text m_ServerName;
        [SerializeField] protected InputField m_Account;
        [SerializeField] Button m_EnterGame;
        [SerializeField] Button m_QQLogin;
        [SerializeField] Button m_WXLogin;
        [SerializeField] Button m_ServerSelect;
        [SerializeField] Button m_SwitchAccount;
        [SerializeField] Button m_Notice;
        [SerializeField] Button m_UserHelp;
        [SerializeField] RichText m_BanHao;
        [SerializeField] RichText[] m_BanHaos;
        [SerializeField] Button m_CleanCache;
 
        LoginModel model { get { return ModelCenter.Instance.GetModel<LoginModel>(); } }
 
        #region Built-in
        protected override void BindController()
        {
 
        }
 
        protected override void AddListeners()
        {
#if UNITY_EDITOR
            m_Account.onEndEdit.AddListener(x => { EnterGame(); });
#endif
            m_EnterGame.SetListener(EnterGame);
            m_QQLogin.SetListener(QQLogin);
            m_WXLogin.SetListener(WXLogin);
            m_ServerSelect.SetListener(OpenServerListWin);
            m_SwitchAccount.SetListener(SwitchAccount);
            m_Notice.SetListener(VeiwNotice);
            if (m_UserHelp)
            {
                m_UserHelp.SetListener(OpenUserHelp);
            }
 
            m_CleanCache.SetListener(ResourcesPath.Instance.CleanCache);
        }
 
        protected override void OnPreOpen()
        {
            ServerListCenter.Instance.RequestPlayerServerList();
            model.isLogined = false;
            ServerListCenter.Instance.FiltrateDefaultServerAndServerGroup();
            m_BanHao.text = string.IsNullOrEmpty(VersionConfig.Get().banHao) ? string.Empty : VersionConfig.Get().banHao;
            int banhaoFlag;
            if (!int.TryParse(VersionConfig.Get().banHao, out banhaoFlag))
            {
                banhaoFlag = 1;
            }
            for (int i = 0; i < m_BanHaos.Length; i++)
            {
                m_BanHaos[i].SetActive(i == (banhaoFlag - 1));
            }
            var sprite = BuiltInLoader.LoadSprite("TB_DL_Logo");
            m_Logo.overrideSprite = sprite;
            m_Logo.SetNativeSize();
            m_Logo.rectTransform.anchoredPosition = VersionConfig.Get().logoPosition;
            m_Notice.SetActive(GameNotice.HasNotice());
 
            m_AlphaTween.SetStartState();
 
            if (FuncSwitchConfig.Has(2))
            {
                var switchAccountJson = JsonMapper.ToObject(FuncSwitchConfig.Get(2).AppIdSwitch);
                if (switchAccountJson.Keys.Contains(VersionConfig.Get().appId) && switchAccountJson[VersionConfig.Get().appId].ToString() == "0")
                {
                    m_SwitchAccount.SetActive(false);
                }
                else
                {
                    m_SwitchAccount.SetActive(true);
                }
            }
            else
            {
                m_SwitchAccount.SetActive(true);
            }
 
            if (m_UserHelp)
            {
                var appId = VersionConfig.Get().appId;
                var branch = VersionConfig.Get().branch;
                m_UserHelp.SetActive(ContactConfig.GetConfig(appId, branch) != null);
            }
 
            m_WaitServerList.SetActive(!ServerListCenter.Instance.serverListGot);
            m_ContainerEnterGame.SetActive(ServerListCenter.Instance.serverListGot);
            m_ContainerAccount.SetActive(ServerListCenter.Instance.serverListGot
                && (VersionConfig.Get().versionAuthority == VersionAuthority.InterTest || VersionConfig.Get().isBanShu));
 
            if (ServerListCenter.Instance.serverListGot)
            {
                ChangeServerInfo(ServerListCenter.Instance.currentServer);
            }
 
            ChangeUserInfo(model.localSaveAccountName);
 
 
            m_EnterGame.SetActive(true);
            m_QQLogin.SetActive(false);
            m_WXLogin.SetActive(false);
 
        }
 
        private void OnLoginOk(ynmbxxjUtil.FP_LoginOk arg0)
        {
        }
 
        protected override void OnAfterOpen()
        {
            ServerListCenter.Instance.serverSelectEvent += OnServerChange;
            ServerListCenter.Instance.onServerListRefreshEvent += OnServerListRefresh;
        }
 
        protected override void OnPreClose()
        {
 
        }
 
        protected override void OnAfterClose()
        {
            ServerListCenter.Instance.serverSelectEvent -= OnServerChange;
            ServerListCenter.Instance.onServerListRefreshEvent -= OnServerListRefresh;
            ynmbxxjUtil.Instance.onFreePlatformLoginOk -= OnLoginOk;
            ynmbxxjUtil.Instance.SendShowFloatWin();
        }
 
        protected override void OnActived()
        {
            base.OnActived();
 
            m_AlphaTween.Play();
            m_AlphaTween.Play(() => { firstOpenEnd = true; });
        }
 
        protected override void LateUpdate()
        {
            base.LateUpdate();
 
            windowInfo.raycastTarget = true;
            model.RequestServerListLoop();
        }
        #endregion
 
        private void ChangeUserInfo(string user)
        {
            m_Account.text = user;
        }
 
 
        private void ChangeServerInfo(ServerData _serverData)
        {
            m_ServerName.text = _serverData.name.Replace("@gm", "");
            m_ServerIP = _serverData.region_domain;
            m_Port = _serverData.login_port;
            m_GamePort = _serverData.game_port;
 
            switch ((ServerState)_serverData.running_status)
            {
                case ServerState.Maintain:
                case ServerState.Predicted:
                    m_ServerState.SetSprite("XT_FWQ_TB4");
                    m_ServerStateDescription.text = Language.GetFromLocal(29);
                    break;
                case ServerState.Normal:
                    m_ServerState.SetSprite("XT_FWQ_TB2");
                    m_ServerStateDescription.text = Language.GetFromLocal(28);
                    break;
                case ServerState.Busy:
                    m_ServerState.SetSprite("XT_FWQ_TB3");
                    m_ServerStateDescription.text = Language.GetFromLocal(27);
                    break;
                case ServerState.Hot:
                    m_ServerState.SetSprite("XT_FWQ_TB1");
                    m_ServerStateDescription.text = Language.GetFromLocal(26);
                    break;
            }
        }
 
        private void OnServerChange()
        {
            ChangeServerInfo(ServerListCenter.Instance.currentServer);
        }
 
        private void OnServerListRefresh()
        {
            m_WaitServerList.SetActive(!ServerListCenter.Instance.serverListGot);
            m_ContainerEnterGame.SetActive(ServerListCenter.Instance.serverListGot);
            m_ContainerAccount.SetActive(ServerListCenter.Instance.serverListGot
                && (VersionConfig.Get().versionAuthority == VersionAuthority.InterTest || VersionConfig.Get().isBanShu));
        }
 
        protected virtual void EnterGame()
        {
 
            if (!ConfigInitiator.IsCreateRoleConfigInited)
            {
                return;
            }
 
            ynmbxxjUtil.Instance.SendHideFloatWin();
 
            Login();
 
            //到这里一定是下载表结束
            InGameDownLoad.Instance.SetDownloadMark();
        }
 
        protected void QQLogin()
        {
            ynmbxxjUtil.Instance.TencentLogin("Login");
        }
 
        protected void WXLogin()
        {
            ynmbxxjUtil.Instance.TencentLogin("Loginwx");
        }
 
        protected void Login()
        {
            var allow = false;
            if (DebugUtility.Instance.isWhiteListAccount)
            {
                allow = true;
            }
            else
            {
                if (ServerListCenter.Instance.currentServer.running_status == (int)ServerState.Maintain
                    || ServerListCenter.Instance.currentServer.running_status == (int)ServerState.Predicted)
                {
                    allow = false;
                }
                else
                {
                    allow = true;
                }
            }
 
            if (!allow)
            {
                switch ((ServerState)ServerListCenter.Instance.currentServer.running_status)
                {
                    case ServerState.Maintain:
                        SysNotifyMgr.Instance.ShowTip("ServerDown");
                        break;
                    case ServerState.Predicted:
                        SysNotifyMgr.Instance.ShowTip("ServerOpen", ServerListCenter.Instance.currentServer.start_date.ToString("dd-MM HH:mm"));
                        break;
                }
 
                return;
            }
 
            if (GameNetSystem.Instance.netState == GameNetSystem.NetState.NerverConnect)
            {
                switch (VersionConfig.Get().versionAuthority)
                {
                    case VersionAuthority.InterTest:
                        if (string.IsNullOrEmpty(m_Account.text))
                        {
                            ServerTipDetails.DisplayNormalTip(Language.Get("L1095"));
                            return;
                        }
 
                        model.AccountLogin(m_Account.text, m_ServerIP, m_Port, m_GamePort);
                        break;
                    case VersionAuthority.Release:
                        model.AccountLogin(m_ServerIP, m_Port, m_GamePort);
                        break;
                }
 
                OperationLogCollect.Instance.RecordLauchEvent(6);
                OperationLogCollect.Instance.RecordEvent(7);
            }
 
        }
 
        private void OpenServerListWin()
        {
            WindowCenter.Instance.Open<ServerListWin>();
        }
 
        private void SwitchAccount()
        {
            ynmbxxjUtil.Instance.FreePlatformLoginout();
            var loginModel = ModelCenter.Instance.GetModel<LoginModel>();
            loginModel.sdkLogined = false;
        }
 
        private void VeiwNotice()
        {
            GameNotice.OpenGameNoticeForce();
        }
 
        private void OpenUserHelp()
        {
            WindowCenter.Instance.OpenFromLocal<UserHelpWin>();
        }
 
    }
 
}