Переглянути джерело

优化douyu管理sdk相关的代码

hexiaojie 1 рік тому
батько
коміт
dd264103cc

+ 7 - 26
GameClient/Assets/Game/HotUpdate/Platform/QDDouYouManager.cs

@@ -32,14 +32,7 @@ namespace GFGGame
 
         public void OnCreateRole()
         {
-            var zoneScene = GameGlobal.zoneScene;
-            var roleInfo = zoneScene.GetComponent<RoleInfosComponent>().GetCurrentRole();
-            
-            string serverName = zoneScene.GetComponent<ServerInfosComponent>().recentlyServerInfo.ServerName;
-
-            QDDouYouManagerInit.Instance.ReportRole((int)DouYouRoleLogReportType.CreateRole,
-                roleInfo.Id.ToString(), 1.ToString(), roleInfo.Name, roleInfo.ServerId.ToString(),
-                serverName);
+            QDManager.PushRoleAction(DouYouRoleLogReportType.CreateRole);
         }
 
         public void OnEnterGame()
@@ -52,8 +45,7 @@ namespace GFGGame
 
             QDDouYouManagerInit.Instance.ReportRoleLogin(roleInfo.Id.ToString(), lvl.ToString(), roleInfo.Name,
                 roleInfo.ServerId.ToString(), serverName);
-            QDDouYouManagerInit.Instance.ReportRole((int)DouYouRoleLogReportType.EnterGame,
-                roleInfo.Id.ToString(), lvl.ToString(), roleInfo.Name, roleInfo.ServerId.ToString(), serverName);
+            QDManager.PushRoleAction(DouYouRoleLogReportType.EnterGame);
         }
 
         public void OnQuitToLoginView()
@@ -69,14 +61,7 @@ namespace GFGGame
 
         public void LoginOutBefore()
         {
-            var zoneScene = GameGlobal.zoneScene;
-            var roleInfo = zoneScene.GetComponent<RoleInfosComponent>().GetCurrentRole();
-            int lvl = GameGlobal.myNumericComponent.GetAsInt(NumericType.Lvl);
-            string serverName = zoneScene.GetComponent<ServerInfosComponent>().recentlyServerInfo.ServerName;
-
-            QDDouYouManagerInit.Instance.ReportRole((int)DouYouRoleLogReportType.ExitGame,
-                roleInfo.Id.ToString(), lvl.ToString(), roleInfo.Name, roleInfo.ServerId.ToString(),
-                serverName);
+            QDManager.PushRoleAction(DouYouRoleLogReportType.ExitGame);
         }
 
         public void Pay(int buyID, int count, string orderID, long price)
@@ -109,18 +94,14 @@ namespace GFGGame
 
         public void Exit()
         {
-            var zoneScene = GameGlobal.zoneScene;
-            var roleInfo = zoneScene.GetComponent<RoleInfosComponent>().GetCurrentRole();
-            int lvl = GameGlobal.myNumericComponent.GetAsInt(NumericType.Lvl);
-            string serverName = zoneScene.GetComponent<ServerInfosComponent>().recentlyServerInfo.ServerName;
-
-            QDDouYouManagerInit.Instance.ReportRole((int)DouYouRoleLogReportType.ExitGame,
-                roleInfo.Id.ToString(), lvl.ToString(), roleInfo.Name, roleInfo.ServerId.ToString(),
-                serverName);
+            QDManager.PushRoleAction(DouYouRoleLogReportType.ExitGame);
             QDDouYouManagerInit.Instance.ExitApp();
         }
     }
 
+    /// <summary>
+    /// SDK回调
+    /// </summary>
     public class DouYouSDKListener : IDouYouSDKListener
     {
         // /// <summary>

+ 39 - 15
GameClient/Assets/Game/HotUpdate/Platform/QDManager.cs

@@ -1,17 +1,17 @@
-using ET;
+using ET;
+using GFGGame.Launcher;
 using UnityEngine;
 
 namespace GFGGame
 {
-
     public class QDManager
     {
         public bool isLogining;
         public string uid;
-        
+
         public static void Init()
         {
-            switch(LauncherConfig.ChannelId)
+            switch (LauncherConfig.ChannelId)
             {
                 default:
                     QDDouYouManager.Instance.Init();
@@ -25,7 +25,7 @@ namespace GFGGame
             switch (LauncherConfig.ChannelId)
             {
                 case (int)ChannelID.TapTap:
-                    
+
                     break;
                 case (int)ChannelID.Test:
                     bool login = GameController.CheckLoginCache(true);
@@ -34,6 +34,7 @@ namespace GFGGame
                         ViewManager.Hide<ModalStatusView>();
                         ViewManager.Show<LoginInputView>();
                     }
+
                     break;
                 case (int)ChannelID.DouYouTest:
                     QDDouYouManager.Instance.Login();
@@ -49,7 +50,7 @@ namespace GFGGame
             switch (LauncherConfig.ChannelId)
             {
                 case (int)ChannelID.TapTap:
-                    
+
                     break;
                 case (int)ChannelID.Test:
 
@@ -68,7 +69,7 @@ namespace GFGGame
             switch (LauncherConfig.ChannelId)
             {
                 case (int)ChannelID.TapTap:
-                    
+
                     break;
                 case (int)ChannelID.Test:
 
@@ -88,7 +89,7 @@ namespace GFGGame
             switch (LauncherConfig.ChannelId)
             {
                 case (int)ChannelID.TapTap:
-                    
+
                     break;
                 case (int)ChannelID.Test:
 
@@ -107,7 +108,7 @@ namespace GFGGame
             switch (LauncherConfig.ChannelId)
             {
                 case (int)ChannelID.TapTap:
-                    
+
                     break;
                 case (int)ChannelID.Test:
 
@@ -130,13 +131,15 @@ namespace GFGGame
             {
                 PlayerPrefs.DeleteKey(GameConst.PASSWORD_LAST_LOGIN_KEY);
             }
+
             switch (LauncherConfig.ChannelId)
             {
                 default:
-                    if(!fromSdkLogoutCallback)
+                    if (!fromSdkLogoutCallback)
                     {
                         QDDouYouManager.Instance.Logout();
                     }
+
                     break;
             }
         }
@@ -157,13 +160,34 @@ namespace GFGGame
             }
         }
 
-        public static bool IsTaptap
+        //上报角色行为给sdk
+        public static void PushRoleAction(DouYouRoleLogReportType reportType)
         {
-            get
-            {
-                return LauncherConfig.ChannelId == (int)ChannelID.TapTap;
-            }
+            //改名上报给sdk
+            var zoneScene = GameGlobal.zoneScene;
+            if (zoneScene == null) return;
+            
+            if (zoneScene.GetComponent<RoleInfosComponent>() == null ||
+                zoneScene.GetComponent<RoleInfosComponent>().IsDisposed) return;
+            
+            var roleInfo = zoneScene.GetComponent<RoleInfosComponent>().GetCurrentRole();
+            if (roleInfo == null) return;
+            
+            if (GameGlobal.myNumericComponent == null) return;
+            int lvl = GameGlobal.myNumericComponent.GetAsInt(NumericType.Lvl);
+ 
+            if (zoneScene.GetComponent<ServerInfosComponent>() == null) return;
+            if (zoneScene.GetComponent<ServerInfosComponent>().recentlyServerInfo == null) return;
+
+            string serverName = zoneScene.GetComponent<ServerInfosComponent>().recentlyServerInfo.ServerName;
+            QDDouYouManagerInit.Instance.ReportRole((int)reportType,
+                roleInfo.Id.ToString(), lvl.ToString(), roleInfo.Name, roleInfo.ServerId.ToString(),
+                serverName);
         }
 
+        public static bool IsTaptap
+        {
+            get { return LauncherConfig.ChannelId == (int)ChannelID.TapTap; }
+        }
     }
 }

+ 8 - 1
GameClient/Assets/Game/Launcher/LauncherConfig.cs

@@ -41,6 +41,8 @@ namespace GFGGame
         public static string updateResPrompt;
         public static int promptSizeMB;
         public static string updateUrl;
+        //新发行给的adId
+        public static string douYouAdId;
 
         public static void InitScriptCompilation()
         {
@@ -91,6 +93,11 @@ namespace GFGGame
             {
                 LauncherConfig.onDebug = int.Parse(result.onDebug);
             }
+
+            if (!string.IsNullOrEmpty(result.douYouAdId))
+            {
+                LauncherConfig.douYouAdId = result.douYouAdId;
+            }
             LauncherConfig.manifest_v = result.manifest_v;
             LauncherConfig.privacy_v = result.privacy_v;
             LauncherConfig.statusPrompt = result.statusPrompt;
@@ -117,7 +124,7 @@ namespace GFGGame
             public string updateResPrompt;
             public string promptSizeMB;
             public string updateUrl;
+            public string douYouAdId;
         }
-
     }
 }

+ 1 - 7
GameClient/Assets/Game/Launcher/Platform/QDDouYouManagerInit.cs

@@ -40,13 +40,7 @@ namespace GFGGame.Launcher
         {
             _douYouMainActivity.Call(functionName, args);
         }
-
-        //临时获取adId,之后需要配置到配置文件里面,已达到热更
-        public string GetAdId()
-        {
-            return "123";
-        }
-
+        
         /// <summary>
         /// 显示登录界面
         /// </summary>

+ 1 - 1
GameClient/Assets/Game/Launcher/Platform/QDManagerInit.cs

@@ -9,7 +9,7 @@ namespace GFGGame.Launcher
             switch (LauncherConfig.ChannelId)
             {
                 default:
-                    QDDouYouManagerInit.Instance.InitSDK(QDDouYouManagerInit.Instance.GetAdId());
+                    QDDouYouManagerInit.Instance.InitSDK(LauncherConfig.douYouAdId);
                     break;
             }
         }

+ 2 - 2
GameClient/ProjectSettings/ProjectSettings.asset

@@ -145,7 +145,7 @@ PlayerSettings:
     16:10: 1
     16:9: 1
     Others: 1
-  bundleVersion: 1.9
+  bundleVersion: 1.8
   preloadedAssets: []
   metroInputSource: 0
   wsaTransparentSwapchain: 0
@@ -254,7 +254,7 @@ PlayerSettings:
   useCustomBaseGradleTemplate: 1
   useCustomGradlePropertiesTemplate: 0
   useCustomProguardFile: 0
-  AndroidTargetArchitectures: 2
+  AndroidTargetArchitectures: 3
   AndroidTargetDevices: 0
   AndroidSplashScreenScale: 2
   androidSplashScreen: {fileID: 2800000, guid: f6233d8fa06ec8f47be121cb17376b7c, type: 3}