|
@@ -5,7 +5,8 @@ namespace ET
|
|
{
|
|
{
|
|
public static class LoginHelper
|
|
public static class LoginHelper
|
|
{
|
|
{
|
|
- public static async ETTask<(int, long)> LoginTest(Scene zoneScene, string address, string account, bool cancelDelete)
|
|
|
|
|
|
+ public static async ETTask<(int, long)> LoginTest(Scene zoneScene, string address, string account,
|
|
|
|
+ bool cancelDelete)
|
|
{
|
|
{
|
|
A2C_LoginAccount a2CLoginAccount = null;
|
|
A2C_LoginAccount a2CLoginAccount = null;
|
|
Session accountSession = null;
|
|
Session accountSession = null;
|
|
@@ -19,7 +20,8 @@ namespace ET
|
|
Version = GameConst.SERVER_VERSION,
|
|
Version = GameConst.SERVER_VERSION,
|
|
PlatformId = LauncherConfig.platformId,
|
|
PlatformId = LauncherConfig.platformId,
|
|
ChannelId = LauncherConfig.ChannelId,
|
|
ChannelId = LauncherConfig.ChannelId,
|
|
- CancelDelete = cancelDelete
|
|
|
|
|
|
+ CancelDelete = cancelDelete,
|
|
|
|
+ Token = QDDouYouManager.Instance.token
|
|
});
|
|
});
|
|
}
|
|
}
|
|
catch (Exception e)
|
|
catch (Exception e)
|
|
@@ -34,12 +36,14 @@ namespace ET
|
|
accountSession?.Dispose();
|
|
accountSession?.Dispose();
|
|
return (a2CLoginAccount.Error, a2CLoginAccount.DeleteTime);
|
|
return (a2CLoginAccount.Error, a2CLoginAccount.DeleteTime);
|
|
}
|
|
}
|
|
|
|
+
|
|
OnLoginSuccess(zoneScene, a2CLoginAccount, accountSession, account);
|
|
OnLoginSuccess(zoneScene, a2CLoginAccount, accountSession, account);
|
|
|
|
|
|
return (ErrorCode.ERR_Success, 0);
|
|
return (ErrorCode.ERR_Success, 0);
|
|
}
|
|
}
|
|
|
|
|
|
- public static async ETTask<(int, long)> Login(Scene zoneScene, string address, string account, string password, bool isMD5, bool cancelDelete)
|
|
|
|
|
|
+ public static async ETTask<(int, long)> Login(Scene zoneScene, string address, string account, string password,
|
|
|
|
+ bool isMD5, bool cancelDelete)
|
|
{
|
|
{
|
|
A2C_LoginAccount a2CLoginAccount = null;
|
|
A2C_LoginAccount a2CLoginAccount = null;
|
|
Session accountSession = null;
|
|
Session accountSession = null;
|
|
@@ -52,6 +56,7 @@ namespace ET
|
|
{
|
|
{
|
|
passwordMD5 = MD5Helper.stringMD5(password);
|
|
passwordMD5 = MD5Helper.stringMD5(password);
|
|
}
|
|
}
|
|
|
|
+
|
|
a2CLoginAccount = (A2C_LoginAccount)await accountSession.Call(new C2A_LoginAccount()
|
|
a2CLoginAccount = (A2C_LoginAccount)await accountSession.Call(new C2A_LoginAccount()
|
|
{
|
|
{
|
|
Account = account,
|
|
Account = account,
|
|
@@ -74,12 +79,14 @@ namespace ET
|
|
accountSession?.Dispose();
|
|
accountSession?.Dispose();
|
|
return (a2CLoginAccount.Error, a2CLoginAccount.DeleteTime);
|
|
return (a2CLoginAccount.Error, a2CLoginAccount.DeleteTime);
|
|
}
|
|
}
|
|
|
|
+
|
|
OnLoginSuccess(zoneScene, a2CLoginAccount, accountSession, account);
|
|
OnLoginSuccess(zoneScene, a2CLoginAccount, accountSession, account);
|
|
|
|
|
|
return (ErrorCode.ERR_Success, 0);
|
|
return (ErrorCode.ERR_Success, 0);
|
|
}
|
|
}
|
|
|
|
|
|
- public static void OnLoginSuccess(Scene zoneScene, A2C_LoginAccount a2CLoginAccount, Session accountSession, string account)
|
|
|
|
|
|
+ public static void OnLoginSuccess(Scene zoneScene, A2C_LoginAccount a2CLoginAccount, Session accountSession,
|
|
|
|
+ string account)
|
|
{
|
|
{
|
|
zoneScene.GetComponent<SessionComponent>().AccountSession = accountSession;
|
|
zoneScene.GetComponent<SessionComponent>().AccountSession = accountSession;
|
|
accountSession.AddComponent<PingComponent>();
|
|
accountSession.AddComponent<PingComponent>();
|
|
@@ -93,7 +100,8 @@ namespace ET
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
- public static async ETTask<int> Register(Scene zoneScene, string address, string account, string password, string name, string identityNum, string code)
|
|
|
|
|
|
+ public static async ETTask<int> Register(Scene zoneScene, string address, string account, string password,
|
|
|
|
+ string name, string identityNum, string code)
|
|
{
|
|
{
|
|
A2C_Register r2C_Register = null;
|
|
A2C_Register r2C_Register = null;
|
|
Session session = null;
|
|
Session session = null;
|
|
@@ -125,6 +133,7 @@ namespace ET
|
|
Log.Debug(e.ToString());
|
|
Log.Debug(e.ToString());
|
|
return ErrorCode.ERR_NetWorkError;
|
|
return ErrorCode.ERR_NetWorkError;
|
|
}
|
|
}
|
|
|
|
+
|
|
return ErrorCode.ERR_Success;
|
|
return ErrorCode.ERR_Success;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -134,11 +143,12 @@ namespace ET
|
|
|
|
|
|
try
|
|
try
|
|
{
|
|
{
|
|
- a2C_GetServerInfos = (A2C_GetServerInfos)await zoneScene.GetComponent<SessionComponent>().AccountSession?.Call(new C2A_GetServerInfos()
|
|
|
|
- {
|
|
|
|
- AccountId = zoneScene.GetComponent<AccountInfoComponent>().AccountId,
|
|
|
|
- Token = zoneScene.GetComponent<AccountInfoComponent>().Token
|
|
|
|
- });
|
|
|
|
|
|
+ a2C_GetServerInfos = (A2C_GetServerInfos)await zoneScene.GetComponent<SessionComponent>().AccountSession
|
|
|
|
+ ?.Call(new C2A_GetServerInfos()
|
|
|
|
+ {
|
|
|
|
+ AccountId = zoneScene.GetComponent<AccountInfoComponent>().AccountId,
|
|
|
|
+ Token = zoneScene.GetComponent<AccountInfoComponent>().Token
|
|
|
|
+ });
|
|
}
|
|
}
|
|
catch (Exception e)
|
|
catch (Exception e)
|
|
{
|
|
{
|
|
@@ -150,6 +160,7 @@ namespace ET
|
|
{
|
|
{
|
|
return a2C_GetServerInfos.Error;
|
|
return a2C_GetServerInfos.Error;
|
|
}
|
|
}
|
|
|
|
+
|
|
zoneScene.GetComponent<ServerInfosComponent>()?.ServerInfoList?.Clear();
|
|
zoneScene.GetComponent<ServerInfosComponent>()?.ServerInfoList?.Clear();
|
|
foreach (var serverInfoProto in a2C_GetServerInfos.ServerInfosList)
|
|
foreach (var serverInfoProto in a2C_GetServerInfos.ServerInfosList)
|
|
{
|
|
{
|
|
@@ -157,6 +168,7 @@ namespace ET
|
|
serverInfo.FromMessage(serverInfoProto);
|
|
serverInfo.FromMessage(serverInfoProto);
|
|
zoneScene.GetComponent<ServerInfosComponent>().Add(serverInfo);
|
|
zoneScene.GetComponent<ServerInfosComponent>().Add(serverInfo);
|
|
}
|
|
}
|
|
|
|
+
|
|
zoneScene.GetComponent<ServerInfosComponent>().SetRecentlyServerInfo(a2C_GetServerInfos.RecentId);
|
|
zoneScene.GetComponent<ServerInfosComponent>().SetRecentlyServerInfo(a2C_GetServerInfos.RecentId);
|
|
|
|
|
|
await ETTask.CompletedTask;
|
|
await ETTask.CompletedTask;
|
|
@@ -169,12 +181,13 @@ namespace ET
|
|
|
|
|
|
try
|
|
try
|
|
{
|
|
{
|
|
- a2C_GetRoles = (A2C_GetRoles)await zoneScene.GetComponent<SessionComponent>().AccountSession.Call(new C2A_GetRoles()
|
|
|
|
- {
|
|
|
|
- AccountId = zoneScene.GetComponent<AccountInfoComponent>().AccountId,
|
|
|
|
- Token = zoneScene.GetComponent<AccountInfoComponent>().Token,
|
|
|
|
- ServerId = zoneScene.GetComponent<ServerInfosComponent>().CurrentServerId,
|
|
|
|
- });
|
|
|
|
|
|
+ a2C_GetRoles = (A2C_GetRoles)await zoneScene.GetComponent<SessionComponent>().AccountSession.Call(
|
|
|
|
+ new C2A_GetRoles()
|
|
|
|
+ {
|
|
|
|
+ AccountId = zoneScene.GetComponent<AccountInfoComponent>().AccountId,
|
|
|
|
+ Token = zoneScene.GetComponent<AccountInfoComponent>().Token,
|
|
|
|
+ ServerId = zoneScene.GetComponent<ServerInfosComponent>().CurrentServerId,
|
|
|
|
+ });
|
|
}
|
|
}
|
|
catch (Exception e)
|
|
catch (Exception e)
|
|
{
|
|
{
|
|
@@ -204,13 +217,14 @@ namespace ET
|
|
A2C_CreateRole a2C_CreateRole = null;
|
|
A2C_CreateRole a2C_CreateRole = null;
|
|
try
|
|
try
|
|
{
|
|
{
|
|
- a2C_CreateRole = (A2C_CreateRole)await zoneScene.GetComponent<SessionComponent>().AccountSession?.Call(new C2A_CreateRole
|
|
|
|
- {
|
|
|
|
- AccountId = zoneScene.GetComponent<AccountInfoComponent>().AccountId,
|
|
|
|
- Token = zoneScene.GetComponent<AccountInfoComponent>().Token,
|
|
|
|
- Name = name,
|
|
|
|
- ServerId = zoneScene.GetComponent<ServerInfosComponent>().CurrentServerId,
|
|
|
|
- });
|
|
|
|
|
|
+ a2C_CreateRole = (A2C_CreateRole)await zoneScene.GetComponent<SessionComponent>().AccountSession?.Call(
|
|
|
|
+ new C2A_CreateRole
|
|
|
|
+ {
|
|
|
|
+ AccountId = zoneScene.GetComponent<AccountInfoComponent>().AccountId,
|
|
|
|
+ Token = zoneScene.GetComponent<AccountInfoComponent>().Token,
|
|
|
|
+ Name = name,
|
|
|
|
+ ServerId = zoneScene.GetComponent<ServerInfosComponent>().CurrentServerId,
|
|
|
|
+ });
|
|
}
|
|
}
|
|
catch (Exception e)
|
|
catch (Exception e)
|
|
{
|
|
{
|
|
@@ -237,13 +251,14 @@ namespace ET
|
|
|
|
|
|
try
|
|
try
|
|
{
|
|
{
|
|
- a2C_DeleteRole = (A2C_DeleteRole)await zoneScene.GetComponent<SessionComponent>().AccountSession?.Call(new C2A_DeleteRole()
|
|
|
|
- {
|
|
|
|
- AccountId = zoneScene.GetComponent<AccountInfoComponent>().AccountId,
|
|
|
|
- Token = zoneScene.GetComponent<AccountInfoComponent>().Token,
|
|
|
|
- RoleInfoId = roleId,
|
|
|
|
- ServerId = zoneScene.GetComponent<ServerInfosComponent>().CurrentServerId,
|
|
|
|
- });
|
|
|
|
|
|
+ a2C_DeleteRole = (A2C_DeleteRole)await zoneScene.GetComponent<SessionComponent>().AccountSession?.Call(
|
|
|
|
+ new C2A_DeleteRole()
|
|
|
|
+ {
|
|
|
|
+ AccountId = zoneScene.GetComponent<AccountInfoComponent>().AccountId,
|
|
|
|
+ Token = zoneScene.GetComponent<AccountInfoComponent>().Token,
|
|
|
|
+ RoleInfoId = roleId,
|
|
|
|
+ ServerId = zoneScene.GetComponent<ServerInfosComponent>().CurrentServerId,
|
|
|
|
+ });
|
|
}
|
|
}
|
|
catch (Exception e)
|
|
catch (Exception e)
|
|
{
|
|
{
|
|
@@ -257,7 +272,10 @@ namespace ET
|
|
return a2C_DeleteRole.Error;
|
|
return a2C_DeleteRole.Error;
|
|
}
|
|
}
|
|
|
|
|
|
- int index = zoneScene.GetComponent<RoleInfosComponent>().RoleInfos.FindIndex((info) => { return info.Id == a2C_DeleteRole.DeleteRoleInfoId; });
|
|
|
|
|
|
+ int index = zoneScene.GetComponent<RoleInfosComponent>().RoleInfos.FindIndex((info) =>
|
|
|
|
+ {
|
|
|
|
+ return info.Id == a2C_DeleteRole.DeleteRoleInfoId;
|
|
|
|
+ });
|
|
zoneScene.GetComponent<RoleInfosComponent>().RoleInfos.RemoveAt(index);
|
|
zoneScene.GetComponent<RoleInfosComponent>().RoleInfos.RemoveAt(index);
|
|
|
|
|
|
await ETTask.CompletedTask;
|
|
await ETTask.CompletedTask;
|
|
@@ -270,12 +288,13 @@ namespace ET
|
|
|
|
|
|
try
|
|
try
|
|
{
|
|
{
|
|
- a2C_GetRealmKey = (A2C_GetRealmKey)await zoneScene.GetComponent<SessionComponent>().AccountSession?.Call(new C2A_GetRealmKey()
|
|
|
|
- {
|
|
|
|
- AccountId = zoneScene.GetComponent<AccountInfoComponent>().AccountId,
|
|
|
|
- Token = zoneScene.GetComponent<AccountInfoComponent>().Token,
|
|
|
|
- ServerId = zoneScene.GetComponent<ServerInfosComponent>().CurrentServerId,
|
|
|
|
- });
|
|
|
|
|
|
+ a2C_GetRealmKey = (A2C_GetRealmKey)await zoneScene.GetComponent<SessionComponent>().AccountSession
|
|
|
|
+ ?.Call(new C2A_GetRealmKey()
|
|
|
|
+ {
|
|
|
|
+ AccountId = zoneScene.GetComponent<AccountInfoComponent>().AccountId,
|
|
|
|
+ Token = zoneScene.GetComponent<AccountInfoComponent>().Token,
|
|
|
|
+ ServerId = zoneScene.GetComponent<ServerInfosComponent>().CurrentServerId,
|
|
|
|
+ });
|
|
}
|
|
}
|
|
catch (Exception e)
|
|
catch (Exception e)
|
|
{
|
|
{
|
|
@@ -303,7 +322,8 @@ namespace ET
|
|
//1.连接Realm,获取分配的Gate
|
|
//1.连接Realm,获取分配的Gate
|
|
R2C_LoginRealm r2C_LoginRealm = null;
|
|
R2C_LoginRealm r2C_LoginRealm = null;
|
|
|
|
|
|
- Session session = zoneScene.GetComponent<NetKcpComponent>().Create(NetworkHelper.ToIPEndPoint(realmAddress));
|
|
|
|
|
|
+ Session session = zoneScene.GetComponent<NetKcpComponent>()
|
|
|
|
+ .Create(NetworkHelper.ToIPEndPoint(realmAddress));
|
|
try
|
|
try
|
|
{
|
|
{
|
|
r2C_LoginRealm = (R2C_LoginRealm)await session.Call(new C2R_LoginRealm()
|
|
r2C_LoginRealm = (R2C_LoginRealm)await session.Call(new C2R_LoginRealm()
|
|
@@ -318,6 +338,7 @@ namespace ET
|
|
session?.Dispose();
|
|
session?.Dispose();
|
|
return ErrorCode.ERR_NetWorkError;
|
|
return ErrorCode.ERR_NetWorkError;
|
|
}
|
|
}
|
|
|
|
+
|
|
session?.Dispose();
|
|
session?.Dispose();
|
|
|
|
|
|
if (r2C_LoginRealm.Error != ErrorCode.ERR_Success)
|
|
if (r2C_LoginRealm.Error != ErrorCode.ERR_Success)
|
|
@@ -326,7 +347,8 @@ namespace ET
|
|
}
|
|
}
|
|
|
|
|
|
LogUtil.LogDev($"GateAddress : {r2C_LoginRealm.GateAddress}");
|
|
LogUtil.LogDev($"GateAddress : {r2C_LoginRealm.GateAddress}");
|
|
- Session gateSession = zoneScene.GetComponent<NetKcpComponent>().Create(NetworkHelper.ToIPEndPoint(r2C_LoginRealm.GateAddress));
|
|
|
|
|
|
+ Session gateSession = zoneScene.GetComponent<NetKcpComponent>()
|
|
|
|
+ .Create(NetworkHelper.ToIPEndPoint(r2C_LoginRealm.GateAddress));
|
|
gateSession.AddComponent<PingComponent>();
|
|
gateSession.AddComponent<PingComponent>();
|
|
gateSession.AddComponent<DisConnectedCompnent>().SessionState = SessionState.Gate;
|
|
gateSession.AddComponent<DisConnectedCompnent>().SessionState = SessionState.Gate;
|
|
zoneScene.GetComponent<SessionComponent>().GateSession = gateSession;
|
|
zoneScene.GetComponent<SessionComponent>().GateSession = gateSession;
|
|
@@ -357,6 +379,7 @@ namespace ET
|
|
zoneScene.GetComponent<SessionComponent>().GateSession?.Dispose();
|
|
zoneScene.GetComponent<SessionComponent>().GateSession?.Dispose();
|
|
return g2C_LoginGate.Error;
|
|
return g2C_LoginGate.Error;
|
|
}
|
|
}
|
|
|
|
+
|
|
LogUtil.LogDev("登陆gate成功!");
|
|
LogUtil.LogDev("登陆gate成功!");
|
|
|
|
|
|
//3.角色正式请求进入游戏逻辑服
|
|
//3.角色正式请求进入游戏逻辑服
|
|
@@ -377,12 +400,15 @@ namespace ET
|
|
//Log.Error(g2C_EnterGame.Error.ToString());
|
|
//Log.Error(g2C_EnterGame.Error.ToString());
|
|
return g2C_EnterGame.Error;
|
|
return g2C_EnterGame.Error;
|
|
}
|
|
}
|
|
|
|
+
|
|
zoneScene.GetComponent<PlayerComponent>().MyId = g2C_EnterGame.MyId;
|
|
zoneScene.GetComponent<PlayerComponent>().MyId = g2C_EnterGame.MyId;
|
|
- var result = await GameGlobal.zoneScene.GetComponent<ObjectWait>().Wait<ET.WaitType.Wait_SceneChangeStart>();
|
|
|
|
- if(result.Error == WaitTypeError.Cancel)
|
|
|
|
|
|
+ var result = await GameGlobal.zoneScene.GetComponent<ObjectWait>()
|
|
|
|
+ .Wait<ET.WaitType.Wait_SceneChangeStart>();
|
|
|
|
+ if (result.Error == WaitTypeError.Cancel)
|
|
{
|
|
{
|
|
return ErrorCode.ERR_Cancel;
|
|
return ErrorCode.ERR_Cancel;
|
|
}
|
|
}
|
|
|
|
+
|
|
LogUtil.LogDev("角色进入游戏成功!");
|
|
LogUtil.LogDev("角色进入游戏成功!");
|
|
return ErrorCode.ERR_Success;
|
|
return ErrorCode.ERR_Success;
|
|
}
|
|
}
|
|
@@ -392,7 +418,8 @@ namespace ET
|
|
A2C_GetLatestNotice response = null;
|
|
A2C_GetLatestNotice response = null;
|
|
try
|
|
try
|
|
{
|
|
{
|
|
- response = (A2C_GetLatestNotice)await GameGlobal.zoneScene.GetComponent<SessionComponent>().AccountSession?.Call(new C2A_GetLatestNotice());
|
|
|
|
|
|
+ response = (A2C_GetLatestNotice)await GameGlobal.zoneScene.GetComponent<SessionComponent>()
|
|
|
|
+ .AccountSession?.Call(new C2A_GetLatestNotice());
|
|
}
|
|
}
|
|
catch (Exception e)
|
|
catch (Exception e)
|
|
{
|
|
{
|
|
@@ -405,6 +432,7 @@ namespace ET
|
|
//Log.Error(response.Error.ToString());
|
|
//Log.Error(response.Error.ToString());
|
|
return response.Error;
|
|
return response.Error;
|
|
}
|
|
}
|
|
|
|
+
|
|
NoticeInfo noticeInfo = new NoticeInfo();
|
|
NoticeInfo noticeInfo = new NoticeInfo();
|
|
noticeInfo.noticeId = response.NoticeId;
|
|
noticeInfo.noticeId = response.NoticeId;
|
|
noticeInfo.title = response.Title;
|
|
noticeInfo.title = response.Title;
|
|
@@ -415,6 +443,7 @@ namespace ET
|
|
|
|
|
|
return ErrorCode.ERR_Success;
|
|
return ErrorCode.ERR_Success;
|
|
}
|
|
}
|
|
|
|
+
|
|
public static async ETTask<(int, string)> ReqRandomRoleName()
|
|
public static async ETTask<(int, string)> ReqRandomRoleName()
|
|
{
|
|
{
|
|
A2C_GetRandomRoleName response = null;
|
|
A2C_GetRandomRoleName response = null;
|
|
@@ -423,8 +452,10 @@ namespace ET
|
|
if (accountSession == null || accountSession.IsDisposed)
|
|
if (accountSession == null || accountSession.IsDisposed)
|
|
{
|
|
{
|
|
notLogin = true;
|
|
notLogin = true;
|
|
- accountSession = GameGlobal.zoneScene.GetComponent<NetKcpComponent>().Create(NetworkHelper.ToIPEndPoint(GameConfig.LoginAddress));
|
|
|
|
|
|
+ accountSession = GameGlobal.zoneScene.GetComponent<NetKcpComponent>()
|
|
|
|
+ .Create(NetworkHelper.ToIPEndPoint(GameConfig.LoginAddress));
|
|
}
|
|
}
|
|
|
|
+
|
|
try
|
|
try
|
|
{
|
|
{
|
|
response = (A2C_GetRandomRoleName)await accountSession?.Call(new C2A_GetRandomRoleName()
|
|
response = (A2C_GetRandomRoleName)await accountSession?.Call(new C2A_GetRandomRoleName()
|
|
@@ -439,6 +470,7 @@ namespace ET
|
|
{
|
|
{
|
|
accountSession?.Dispose();
|
|
accountSession?.Dispose();
|
|
}
|
|
}
|
|
|
|
+
|
|
return (ErrorCode.ERR_NetWorkError, "");
|
|
return (ErrorCode.ERR_NetWorkError, "");
|
|
}
|
|
}
|
|
|
|
|
|
@@ -449,6 +481,7 @@ namespace ET
|
|
{
|
|
{
|
|
accountSession?.Dispose();
|
|
accountSession?.Dispose();
|
|
}
|
|
}
|
|
|
|
+
|
|
return (ErrorCode.ERR_NetWorkError, "");
|
|
return (ErrorCode.ERR_NetWorkError, "");
|
|
}
|
|
}
|
|
|
|
|
|
@@ -456,6 +489,7 @@ namespace ET
|
|
{
|
|
{
|
|
accountSession?.Dispose();
|
|
accountSession?.Dispose();
|
|
}
|
|
}
|
|
|
|
+
|
|
return (ErrorCode.ERR_Success, response.Name);
|
|
return (ErrorCode.ERR_Success, response.Name);
|
|
}
|
|
}
|
|
}
|
|
}
|