防沉迷逻辑调整
parent
1578e86e94
commit
98707ed4a8
|
|
@ -34,6 +34,7 @@
|
|||
LevelCharacterArriveBlock,
|
||||
|
||||
LoginComplete,//当LoginOK时发送消息
|
||||
LoginOut,//当登出时发送消息
|
||||
|
||||
LevelBattleBegin,
|
||||
LevelComplete,
|
||||
|
|
|
|||
|
|
@ -102,7 +102,7 @@ namespace Gameplay.Net
|
|||
GameSettingManager.Instance.Init();
|
||||
}
|
||||
EventManager.Instance.Send(EventManager.EventName.LoginComplete);
|
||||
|
||||
LoginController.Instance.OnLoginOK();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -130,6 +130,8 @@ namespace Gameplay.Net
|
|||
m_Parts[i].OnLogout();
|
||||
}
|
||||
}
|
||||
EventManager.Instance.Send(EventManager.EventName.LoginOut);
|
||||
LoginController.Instance.OnLogout();
|
||||
}
|
||||
|
||||
public void StartLogin(NLDPB.LoginType nType, string account)
|
||||
|
|
|
|||
|
|
@ -136,7 +136,12 @@ namespace Gameplay.Net
|
|||
DebugUtil.Log("服务器断开连接!当前处于防沉迷限制");
|
||||
UI_LongTipController.Open(onClose: () =>
|
||||
{
|
||||
GameClientReconnect.BackToStart();
|
||||
var curState = GameStateManager.Instance.GetCurState();
|
||||
if (curState is not GameStateStart)
|
||||
{
|
||||
GameStateManager.Instance.ChangeState(new GameStateStart());
|
||||
}
|
||||
Actor.Instance.OnLogout();
|
||||
}).Forget();
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -428,7 +428,7 @@ public class UI_StartGameInterfaceController : UIWindow
|
|||
{
|
||||
SetLoginType(LoginType.Account);
|
||||
}
|
||||
if (loginSaveData.LoginByAccount && loginSaveData.rememberPassword)
|
||||
if (loginSaveData.LoginByAccount && loginSaveData.rememberPassword && LoginController.Instance.AutoLogin)
|
||||
{
|
||||
DebugUtil.Log("已有账号密码,自动登录");
|
||||
LoginAction();
|
||||
|
|
@ -468,6 +468,7 @@ public class UI_StartGameInterfaceController : UIWindow
|
|||
Text_UID.gameObject.SetActive(false);
|
||||
|
||||
EventManager.Instance.Register(EventManager.EventName.LoginComplete, OnLoginOK);
|
||||
EventManager.Instance.Register(EventManager.EventName.LoginOut, OnLogoutComplete);
|
||||
//EventManager.Instance.Register(Framework.EventManager.EventName.NetError, OnCancelCurConnect);
|
||||
EventManager.Instance.Register(EventManager.EventName.PhoneCodeLoginSuc, OnPhoneCodeLoginSuc);
|
||||
EventManager.Instance.Register<string>(EventManager.EventName.PhoneCodeLoginFail, OnPhoneCodeLoginFailed);
|
||||
|
|
@ -476,7 +477,10 @@ public class UI_StartGameInterfaceController : UIWindow
|
|||
//if (loginSaveData.LoginByPhone)//手机号Token自动登录
|
||||
//{
|
||||
// PhoneVerifyTool.Instance.RefreshToken = loginSaveData.AuthCode;
|
||||
// Actor.Instance.StartLogin(NLDPB.LoginType.Phxhphone, loginSaveData.phoneNumber);
|
||||
// PhoneVerifyTool.Instance.AccessTokenCode = string.Empty;
|
||||
// PhoneVerifyTool.Instance.RefreshTokenRequest();
|
||||
//
|
||||
// //Actor.Instance.StartLogin(NLDPB.LoginType.Phxhphone, loginSaveData.phoneNumber);
|
||||
//}
|
||||
}
|
||||
|
||||
|
|
@ -666,7 +670,7 @@ public class UI_StartGameInterfaceController : UIWindow
|
|||
|
||||
void OnLoginOK()
|
||||
{
|
||||
loginOK = true;
|
||||
//loginOK = true;
|
||||
HideLoginPanel();
|
||||
|
||||
loginSaveData = StorageMgr.Instance.GetStorage<LoginData>("LoginData");
|
||||
|
|
@ -691,6 +695,17 @@ public class UI_StartGameInterfaceController : UIWindow
|
|||
UI_NoticeWindowController.Open().Forget();
|
||||
}
|
||||
}
|
||||
void OnLogoutComplete()
|
||||
{
|
||||
if (loginSaveData.LoginByPhone)
|
||||
{
|
||||
SetLoginType(LoginType.PhoneCode);
|
||||
}
|
||||
else
|
||||
{
|
||||
SetLoginType(LoginType.Account);
|
||||
}
|
||||
}
|
||||
|
||||
void OnPhoneCodeRequestFailed(string errorMsg)
|
||||
{
|
||||
|
|
@ -728,21 +743,21 @@ public class UI_StartGameInterfaceController : UIWindow
|
|||
/// </summary>
|
||||
void OnCancelCurConnect()
|
||||
{
|
||||
if (loginOK)//TODO 点开用户中心退出原先账号是否需要断开连接
|
||||
if (LoginController.Instance.IsLogin)//TODO 点开用户中心退出原先账号是否需要断开连接
|
||||
{
|
||||
DebugUtil.Log("登出!断开连接");
|
||||
Actor.Instance.OnLogout();
|
||||
NetManager.Instance.CloseClient();
|
||||
loginOK = false;
|
||||
//NetManager.Instance.CloseClient();
|
||||
//loginOK = false;
|
||||
}
|
||||
if (loginSaveData.LoginByPhone)
|
||||
{
|
||||
SetLoginType(LoginType.PhoneCode);
|
||||
}
|
||||
else
|
||||
{
|
||||
SetLoginType(LoginType.Account);
|
||||
}
|
||||
//if (loginSaveData.LoginByPhone)
|
||||
//{
|
||||
// SetLoginType(LoginType.PhoneCode);
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
// SetLoginType(LoginType.Account);
|
||||
//}
|
||||
}
|
||||
|
||||
async void OnNoticeClick()
|
||||
|
|
@ -822,3 +837,36 @@ public class UI_StartGameInterfaceController : UIWindow
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class LoginController : Singlenton<LoginController>
|
||||
{
|
||||
bool autoLogin = true;//第一次尝试自动登录
|
||||
public bool AutoLogin
|
||||
{
|
||||
get { return autoLogin; }
|
||||
}
|
||||
|
||||
bool isLogin = false;
|
||||
public bool IsLogin
|
||||
{
|
||||
get { return isLogin; }
|
||||
}
|
||||
|
||||
public LoginController()
|
||||
{
|
||||
autoLogin = true;
|
||||
isLogin = false;
|
||||
}
|
||||
|
||||
public void OnLogout()
|
||||
{
|
||||
autoLogin = false;
|
||||
isLogin = false;
|
||||
}
|
||||
|
||||
public void OnLoginOK()
|
||||
{
|
||||
autoLogin = false;
|
||||
isLogin = true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue