using ET; using UnityEngine; namespace GFGGame { public class LoginController { public static async ET.ETTask CheckVersion() { ViewManager.Show("连接中..."); int errorCode = 0; errorCode = await ET.LoginHelper.CheckVersion(GameGlobal.zoneScene, ET.ConstValue.LoginAddress, GameConst.SERVER_VERSION); ViewManager.Hide(); 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("登录中..."); int errorCode = await ET.LoginHelper.Login(GameGlobal.zoneScene, ET.ConstValue.LoginAddress, account, password, isMD5); ViewManager.Hide(); if (errorCode == ET.ErrorCode.ERR_Success) { GameGlobal.isVisitor = false; ViewManager.Hide(); ViewManager.Hide(); AccountInfoComponent accountInfoComponent = GameGlobal.zoneScene.GetComponent(); 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(); } } } public static async ETTask Register(string account, string password, string name, string identityNum, string code) { ViewManager.Show("注册中..."); int errorCode = await LoginHelper.Register(GameGlobal.zoneScene, ET.ConstValue.LoginAddress, account, password, name, identityNum, code); ViewManager.Hide(); if (errorCode == ErrorCode.ERR_Success) { Login(account, password).Coroutine(); } else { ErrorCodeController.Handler(errorCode); } } } }