|
@@ -19,6 +19,42 @@ namespace GFGGame
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ public static async ET.ETTask LoginTest(string account)
|
|
|
+ {
|
|
|
+ ViewManager.Show<ModalStatusView>("登录中...");
|
|
|
+ int errorCode = await ET.LoginHelper.LoginTest(GameGlobal.zoneScene, ET.ConstValue.LoginAddress, account);
|
|
|
+
|
|
|
+ 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
|
|
|
+ {
|
|
|
+ PlayerPrefs.SetString(GameConst.ACCOUNT_LAST_LOGIN_KEY, account);
|
|
|
+ PlayerPrefs.DeleteKey(GameConst.PASSWORD_LAST_LOGIN_KEY);
|
|
|
+ }
|
|
|
+ GameController.CheckSpecialAccount("sygfg");
|
|
|
+ LocalCache.SetBool(GameConst.LAST_LOGIN_IS_VISITOR_KEY, GameGlobal.isVisitor);
|
|
|
+ PlayerPrefs.Save();
|
|
|
+
|
|
|
+ await OnLoginSuccess();
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ OnLoginFail(errorCode);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
public static async ET.ETTask Login(string account, string password, bool isMD5 = false)
|
|
|
{
|
|
|
ViewManager.Show<ModalStatusView>("登录中...");
|
|
@@ -50,26 +86,36 @@ namespace GFGGame
|
|
|
GameController.CheckSpecialAccount(account);
|
|
|
LocalCache.SetBool(GameConst.LAST_LOGIN_IS_VISITOR_KEY, GameGlobal.isVisitor);
|
|
|
PlayerPrefs.Save();
|
|
|
- await GetServerInfos();
|
|
|
- ServerInfosComponent serverInfosComponent = GameGlobal.zoneScene.GetComponent<ServerInfosComponent>();
|
|
|
-
|
|
|
- if (serverInfosComponent.ServerInfoList.Count > 1)
|
|
|
- {
|
|
|
- ViewManager.Hide<ModalStatusView>();
|
|
|
- EventAgent.DispatchEvent(ConstMessage.SERVER_CHANGE, serverInfosComponent.CurrentServerId);
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- await GetRoles();
|
|
|
- }
|
|
|
+ await OnLoginSuccess();
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
+ OnLoginFail(errorCode);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private static async ETTask OnLoginSuccess()
|
|
|
+ {
|
|
|
+ await GetServerInfos();
|
|
|
+ ServerInfosComponent serverInfosComponent = GameGlobal.zoneScene.GetComponent<ServerInfosComponent>();
|
|
|
+
|
|
|
+ if (serverInfosComponent.ServerInfoList.Count > 1)
|
|
|
+ {
|
|
|
ViewManager.Hide<ModalStatusView>();
|
|
|
- if (ErrorCodeController.Handler(errorCode))
|
|
|
- {
|
|
|
- ViewManager.Show<LoginInputView>();
|
|
|
- }
|
|
|
+ EventAgent.DispatchEvent(ConstMessage.SERVER_CHANGE, serverInfosComponent.CurrentServerId);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ await GetRoles();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private static void OnLoginFail(int errorCode)
|
|
|
+ {
|
|
|
+ ViewManager.Hide<ModalStatusView>();
|
|
|
+ if (ErrorCodeController.Handler(errorCode))
|
|
|
+ {
|
|
|
+ ViewManager.Show<LoginInputView>();
|
|
|
}
|
|
|
}
|
|
|
|