1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980 |
- using ET;
- using UnityEngine;
- namespace GFGGame
- {
- public class LoginController
- {
- public static async ET.ETTask CheckVersion()
- {
- ViewManager.Show<ModalStatusView>("连接中...");
- int errorCode = 0;
- errorCode = await ET.LoginHelper.CheckVersion(GameGlobal.zoneScene, ET.ConstValue.LoginAddress, GameConst.SERVER_VERSION);
- ViewManager.Hide<ModalStatusView>();
- if (errorCode != ET.ErrorCode.ERR_Success)
- {
- ErrorCodeController.Handler(errorCode);
- await ETTask.Create();
- }
- }
- public static async ET.ETTask Login(string account, string password, bool isMD5 = false)
- {
- ViewManager.Show<ModalStatusView>("登录中...");
- int errorCode = await ET.LoginHelper.Login(GameGlobal.zoneScene, ET.ConstValue.LoginAddress, account, password, isMD5);
- ViewManager.Hide<ModalStatusView>();
- if (errorCode == ET.ErrorCode.ERR_Success)
- {
- GameGlobal.isVisitor = false;
- ViewManager.Hide<LoginInputView>();
- ViewManager.Hide<RegisterView>();
- AccountInfoComponent accountInfoComponent = GameGlobal.zoneScene.GetComponent<AccountInfoComponent>();
- GameGlobal.userId = accountInfoComponent.AccountId;
- GameGlobal.userAge = accountInfoComponent.Age;
- if (GameGlobal.isVisitor)
- {
- //PlayerPrefs.SetFloat(GameConst.VISITOR_ID_KEY, GameGlobal.userId);
- }
- else
- {
- var passwordMD5 = password;
- //密码禁止明文传输
- if (!isMD5)
- {
- passwordMD5 = MD5Helper.stringMD5(password);
- }
- PlayerPrefs.SetString(GameConst.ACCOUNT_LAST_LOGIN_KEY, account);
- PlayerPrefs.SetString(GameConst.PASSWORD_LAST_LOGIN_KEY, passwordMD5);
- }
- GameController.CheckSpecialAccount(account);
- LocalCache.SetBool(GameConst.LAST_LOGIN_IS_VISITOR_KEY, GameGlobal.isVisitor);
- PlayerPrefs.Save();
- GameProxy.ReqRoleInfo(GameGlobal.userId);
- }
- else
- {
- if(ErrorCodeController.Handler(errorCode))
- {
- ViewManager.Show<LoginInputView>();
- }
- }
- }
- public static async ETTask Register(string account, string password, string name, string identityNum, string code)
- {
- ViewManager.Show<ModalStatusView>("注册中...");
- int errorCode = await LoginHelper.Register(GameGlobal.zoneScene, ET.ConstValue.LoginAddress, account, password, name, identityNum, code);
- ViewManager.Hide<ModalStatusView>();
- if (errorCode == ErrorCode.ERR_Success)
- {
- Login(account, password).Coroutine();
- }
- else
- {
- ErrorCodeController.Handler(errorCode);
- }
- }
- }
- }
|