Quellcode durchsuchen

接入douyou sdk 基本完成,等待测试

hexiaojie vor 1 Jahr
Ursprung
Commit
aef7147193

+ 77 - 43
GameClient/Assets/Game/HotUpdate/ETCodes/Hotfix/App/Login/LoginHelper.cs

@@ -5,7 +5,8 @@ namespace ET
 {
     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;
             Session accountSession = null;
@@ -19,7 +20,8 @@ namespace ET
                     Version = GameConst.SERVER_VERSION,
                     PlatformId = LauncherConfig.platformId,
                     ChannelId = LauncherConfig.ChannelId,
-                    CancelDelete = cancelDelete
+                    CancelDelete = cancelDelete,
+                    Token = QDDouYouManager.Instance.token
                 });
             }
             catch (Exception e)
@@ -34,12 +36,14 @@ namespace ET
                 accountSession?.Dispose();
                 return (a2CLoginAccount.Error, a2CLoginAccount.DeleteTime);
             }
+
             OnLoginSuccess(zoneScene, a2CLoginAccount, accountSession, account);
 
             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;
             Session accountSession = null;
@@ -52,6 +56,7 @@ namespace ET
                 {
                     passwordMD5 = MD5Helper.stringMD5(password);
                 }
+
                 a2CLoginAccount = (A2C_LoginAccount)await accountSession.Call(new C2A_LoginAccount()
                 {
                     Account = account,
@@ -74,12 +79,14 @@ namespace ET
                 accountSession?.Dispose();
                 return (a2CLoginAccount.Error, a2CLoginAccount.DeleteTime);
             }
+
             OnLoginSuccess(zoneScene, a2CLoginAccount, accountSession, account);
 
             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;
             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;
             Session session = null;
@@ -125,6 +133,7 @@ namespace ET
                 Log.Debug(e.ToString());
                 return ErrorCode.ERR_NetWorkError;
             }
+
             return ErrorCode.ERR_Success;
         }
 
@@ -134,11 +143,12 @@ namespace ET
 
             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)
             {
@@ -150,6 +160,7 @@ namespace ET
             {
                 return a2C_GetServerInfos.Error;
             }
+
             zoneScene.GetComponent<ServerInfosComponent>()?.ServerInfoList?.Clear();
             foreach (var serverInfoProto in a2C_GetServerInfos.ServerInfosList)
             {
@@ -157,6 +168,7 @@ namespace ET
                 serverInfo.FromMessage(serverInfoProto);
                 zoneScene.GetComponent<ServerInfosComponent>().Add(serverInfo);
             }
+
             zoneScene.GetComponent<ServerInfosComponent>().SetRecentlyServerInfo(a2C_GetServerInfos.RecentId);
 
             await ETTask.CompletedTask;
@@ -169,12 +181,13 @@ namespace ET
 
             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)
             {
@@ -204,13 +217,14 @@ namespace ET
             A2C_CreateRole a2C_CreateRole = null;
             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)
             {
@@ -237,13 +251,14 @@ namespace ET
 
             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)
             {
@@ -257,7 +272,10 @@ namespace ET
                 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);
 
             await ETTask.CompletedTask;
@@ -270,12 +288,13 @@ namespace ET
 
             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)
             {
@@ -303,7 +322,8 @@ namespace ET
             //1.连接Realm,获取分配的Gate
             R2C_LoginRealm r2C_LoginRealm = null;
 
-            Session session = zoneScene.GetComponent<NetKcpComponent>().Create(NetworkHelper.ToIPEndPoint(realmAddress));
+            Session session = zoneScene.GetComponent<NetKcpComponent>()
+                .Create(NetworkHelper.ToIPEndPoint(realmAddress));
             try
             {
                 r2C_LoginRealm = (R2C_LoginRealm)await session.Call(new C2R_LoginRealm()
@@ -318,6 +338,7 @@ namespace ET
                 session?.Dispose();
                 return ErrorCode.ERR_NetWorkError;
             }
+
             session?.Dispose();
 
             if (r2C_LoginRealm.Error != ErrorCode.ERR_Success)
@@ -326,7 +347,8 @@ namespace ET
             }
 
             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<DisConnectedCompnent>().SessionState = SessionState.Gate;
             zoneScene.GetComponent<SessionComponent>().GateSession = gateSession;
@@ -357,6 +379,7 @@ namespace ET
                 zoneScene.GetComponent<SessionComponent>().GateSession?.Dispose();
                 return g2C_LoginGate.Error;
             }
+
             LogUtil.LogDev("登陆gate成功!");
 
             //3.角色正式请求进入游戏逻辑服
@@ -377,12 +400,15 @@ namespace ET
                 //Log.Error(g2C_EnterGame.Error.ToString());
                 return g2C_EnterGame.Error;
             }
+
             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;
             }
+
             LogUtil.LogDev("角色进入游戏成功!");
             return ErrorCode.ERR_Success;
         }
@@ -392,7 +418,8 @@ namespace ET
             A2C_GetLatestNotice response = null;
             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)
             {
@@ -405,6 +432,7 @@ namespace ET
                 //Log.Error(response.Error.ToString());
                 return response.Error;
             }
+
             NoticeInfo noticeInfo = new NoticeInfo();
             noticeInfo.noticeId = response.NoticeId;
             noticeInfo.title = response.Title;
@@ -415,6 +443,7 @@ namespace ET
 
             return ErrorCode.ERR_Success;
         }
+
         public static async ETTask<(int, string)> ReqRandomRoleName()
         {
             A2C_GetRandomRoleName response = null;
@@ -423,8 +452,10 @@ namespace ET
             if (accountSession == null || accountSession.IsDisposed)
             {
                 notLogin = true;
-                accountSession = GameGlobal.zoneScene.GetComponent<NetKcpComponent>().Create(NetworkHelper.ToIPEndPoint(GameConfig.LoginAddress));
+                accountSession = GameGlobal.zoneScene.GetComponent<NetKcpComponent>()
+                    .Create(NetworkHelper.ToIPEndPoint(GameConfig.LoginAddress));
             }
+
             try
             {
                 response = (A2C_GetRandomRoleName)await accountSession?.Call(new C2A_GetRandomRoleName()
@@ -439,6 +470,7 @@ namespace ET
                 {
                     accountSession?.Dispose();
                 }
+
                 return (ErrorCode.ERR_NetWorkError, "");
             }
 
@@ -449,6 +481,7 @@ namespace ET
                 {
                     accountSession?.Dispose();
                 }
+
                 return (ErrorCode.ERR_NetWorkError, "");
             }
 
@@ -456,6 +489,7 @@ namespace ET
             {
                 accountSession?.Dispose();
             }
+
             return (ErrorCode.ERR_Success, response.Name);
         }
     }

+ 3 - 2
GameClient/Assets/Game/HotUpdate/Platform/QDDouYouManager.cs

@@ -101,10 +101,11 @@ namespace GFGGame
             var roleInfo = zoneScene.GetComponent<RoleInfosComponent>().GetCurrentRole();
             string serverName = zoneScene.GetComponent<ServerInfosComponent>().recentlyServerInfo.ServerName;
 
+            //自定义参数
+            string other = orderID + "|gfg|" + roleInfo.Id;
             QDDouYouManagerInit.Instance.ShowSwitchPayment(orderID, price.ToString(), buyID.ToString(),
                 shopCfg.productName, itemCfg.desc,
-                roleInfo.ServerId.ToString(), serverName, roleInfo.Id.ToString(), roleInfo.Name, lvl.ToString(),
-                "Other");
+                roleInfo.ServerId.ToString(), serverName, roleInfo.Id.ToString(), roleInfo.Name, lvl.ToString(), other);
         }
 
         public void Exit()

+ 1 - 1
GameClient/Assets/Game/HotUpdate/Platform/QDManager.cs

@@ -39,7 +39,7 @@ namespace GFGGame
                     QDDouYouManager.Instance.Login();
                     break;
                 default:
-                    QDDouYouManager.Instance.Login();
+                    //QDDouYouManager.Instance.Login();
                     break;
             }
         }

+ 28 - 17
GameClient/Assets/Game/HotUpdate/Views/Login/LoginView.cs

@@ -16,7 +16,6 @@ namespace GFGGame
 
         public override void Dispose()
         {
-
             if (_sceneObject != null)
             {
                 GameObject.DestroyImmediate(_sceneObject);
@@ -28,6 +27,7 @@ namespace GFGGame
                 _ui.Dispose();
                 _ui = null;
             }
+
             base.Dispose();
         }
 
@@ -59,6 +59,7 @@ namespace GFGGame
             _ui.m_loaEventc.onClick.Add(() => { FullScreenTextController.Show("event:c"); });
             //_ui.m_btnAgree.onClick.Add(OnBtnAgreeCklick);
         }
+
         protected override void AddEventListener()
         {
             base.AddEventListener();
@@ -67,14 +68,17 @@ namespace GFGGame
             EventAgent.AddEventListener(ConstMessage.ON_PLATFORM_SDK_LOGINED, OnPlatformLogined);
             EventAgent.AddEventListener(ConstMessage.OUT_LOGIN, OnOutLoginSuccess);
         }
+
         protected override void OnShown()
         {
             base.OnShown();
             MusicManager.Instance.PlayCroutine(ResPathUtil.GetMusicPath(ConstMusicName.DEFAULT));
             if (_sceneObject == null)
             {
-                _sceneObject = PrefabManager.Instance.InstantiateSync(ResPathUtil.GetLoginResPath("LoginSkin1/SceneLogin"));
+                _sceneObject =
+                    PrefabManager.Instance.InstantiateSync(ResPathUtil.GetLoginResPath("LoginSkin1/SceneLogin"));
             }
+
             // SceneController.UpdateLoginScene(_sceneObject);
             ServerInfosComponent serverInfosComponent = GameGlobal.zoneScene.GetComponent<ServerInfosComponent>();
             ServerInfo recentlyServerInfo = serverInfosComponent.recentlyServerInfo;
@@ -85,24 +89,22 @@ namespace GFGGame
             {
                 var date = DateTimeUtil.LongTimeStampToDateTime(GameConfig.openTime);
                 string minuteText = "";
-                if(date.Minute > 0)
+                if (date.Minute > 0)
                 {
                     minuteText = date.Minute + "分";
                 }
+
                 AlertUI.Show($"    亲爱的研究员,万世镜将于{date.Year}年{date.Month}月{date.Day}日{date.Hour}点{minuteText}开放,敬请期待!")
-                        .SetLeftButton(true, "好的", (obj) =>
-                        {
-                            Application.Quit();
-                        });
+                    .SetLeftButton(true, "好的", (obj) => { Application.Quit(); });
                 return;
             }
+
             if (!autoLogined)
             {
                 autoLogined = true;
                 ResetLoginButton();
                 TryLogin();
             }
-
         }
 
         protected override void OnHide()
@@ -113,8 +115,10 @@ namespace GFGGame
                 PrefabManager.Instance.Restore(_sceneObject);
                 _sceneObject = null;
             }
+
             base.OnHide();
         }
+
         protected override void RemoveEventListener()
         {
             base.RemoveEventListener();
@@ -132,8 +136,10 @@ namespace GFGGame
                 _ui.m_btnChange.visible = false;
                 return;
             }
+
             _ui.m_btnChange.visible = serverInfosComponent.ServerInfoList.Count > 1;
-            _ui.m_btnChange.title = string.Format("{0}区  {1}", NumberUtil.GetChiniseNumberText((int)info.Id), info.ServerName);
+            _ui.m_btnChange.title =
+                string.Format("{0}区  {1}", NumberUtil.GetChiniseNumberText((int)info.Id), info.ServerName);
 
             LogServerHelperHttp.SendNodeLog((int)LogNode.ShowSelectServer);
         }
@@ -141,7 +147,7 @@ namespace GFGGame
         private void OnPlatformLogined(EventContext context)
         {
             var account = (string)context.data;
-            if(!string.IsNullOrEmpty(account))
+            if (!string.IsNullOrEmpty(account))
             {
                 _ui.m_btnTapLogin.visible = false;
                 LoginController.LoginTest(account).Coroutine();
@@ -166,18 +172,23 @@ namespace GFGGame
 
             UpdateServer(serverInfosComponent.ServerInfoList[serverInfosComponent.CurrentServerId]);
         }
+
         private void OnBtnChangeClick()
         {
             ViewManager.Show<ServerListView>();
         }
+
         private void OnClickBtnNotice()
         {
-            if (NoticeDataManager.Instance.LastNoticeInfo == null || NoticeDataManager.Instance.LastNoticeInfo.noticeId == 0)
+            if (NoticeDataManager.Instance.LastNoticeInfo == null ||
+                NoticeDataManager.Instance.LastNoticeInfo.noticeId == 0)
             {
                 PromptController.Instance.ShowFloatTextPrompt("暂无公告发布");
                 return;
             }
-            ViewManager.Show<SystemNoticeView>(new object[] { NoticeDataManager.Instance.LastNoticeInfo.title, NoticeDataManager.Instance.LastNoticeInfo.content });
+
+            ViewManager.Show<SystemNoticeView>(new object[]
+                { NoticeDataManager.Instance.LastNoticeInfo.title, NoticeDataManager.Instance.LastNoticeInfo.content });
         }
 
         private void OnClickBtnStart()
@@ -191,6 +202,7 @@ namespace GFGGame
             QDDouYouManager.Instance.LoginOutBefore();
             QDManager.Logout(false);
         }
+
         private void OnClickBtnAge()
         {
             ViewManager.Show<SystemNoticeView>(new object[] { LoginController.ageTipsTitle, LoginController.ageTips });
@@ -210,13 +222,12 @@ namespace GFGGame
                     {
                         LauncherConfig.statusPrompt = "游戏正在更新维护中,请稍后再试。";
                     }
+
                     AlertSystem.Show(LauncherConfig.statusPrompt)
-                        .SetLeftButton(true, "知道了", (data) =>
-                        {
-                            Application.Quit();
-                        });
+                        .SetLeftButton(true, "知道了", (data) => { Application.Quit(); });
                     return;
                 }
+
                 var serverInfosComponent = GameGlobal.zoneScene.GetComponent<ServerInfosComponent>();
                 if (serverInfosComponent.ServerInfoList.Count <= 0)
                 {
@@ -229,10 +240,10 @@ namespace GFGGame
                         PromptController.Instance.ShowFloatTextPrompt("请仔细阅读并同意游戏用户协议、隐私保护指引、儿童隐私政策");
                         return;
                     }
+
                     LoginController.GetRoles().Coroutine();
                 }
             });
-
         }
 
         private void OnOutLoginSuccess(EventContext context)