Pārlūkot izejas kodu

WildAttack游玩时长统计

lvjincheng 2 gadi atpakaļ
vecāks
revīzija
9d88df878a

+ 1 - 1
Assets/BowArrow/Resources/app-version.txt

@@ -1 +1 @@
-2023-04-21-A
+青凤鸾-新增塔防-2023-7-17

+ 16 - 6
Assets/BowArrow/Scripts/Expand/UserGameAnalyse1.cs

@@ -3,10 +3,11 @@ using System.Collections.Generic;
 using UnityEngine;
 using UnityEngine.SceneManagement;
 
-//打鸭子专用
+//打鸭子,塔防
 /* 用户游戏情况统计分析-主要向服务器是上传用户游戏数据 */
 public class UserGameAnalyse1 : MonoBehaviour
 {
+    string targetScene;
     int gameType;
     long startTime; //毫秒
     float duration; //秒
@@ -15,16 +16,25 @@ public class UserGameAnalyse1 : MonoBehaviour
 
     private static UserGameAnalyse1 _Instance;
 
-    public static void CreateWhenGameStart() {
+    public static void CreateWhenGameStart(int gameType) {
         if (_Instance) return;
-        new GameObject("UserGameAnaly1").AddComponent<UserGameAnalyse1>();
+        UserGameAnalyse1 userGameAnalyse = new GameObject("UserGameAnaly1").AddComponent<UserGameAnalyse1>();
+        userGameAnalyse.gameType = gameType;
+        switch (gameType)
+        {
+            case 13:
+                userGameAnalyse.targetScene = "DuckHunter";
+                break;
+            case 14:
+                userGameAnalyse.targetScene = "WildAttack";
+                break;
+        }
     }
 
     void Awake()
     {
         _Instance = this;
         DontDestroyOnLoad(gameObject);
-        gameType = 13;
         startTime = JCUnityLib.TimeUtils.GetTimestamp();
         sceneTimeOnStart = Time.realtimeSinceStartup;
     }
@@ -55,12 +65,12 @@ public class UserGameAnalyse1 : MonoBehaviour
         if (UserPlayer.ins != null) 
         {
             UserPlayer.ins.call("UserGameAnalyseComp.uploadUserGameRecord", gameType, startTime, durationTime);
-            Debug.Log("上传用户打鸭子游戏时长统计数据:" + durationTime);
+            Debug.Log("上传" + targetScene + "(" + gameType + ")游戏时长统计数据:" + durationTime);
         }
     }
 
     bool IsTargetScene()
     {
-        return SceneManager.GetActiveScene().name == "DuckHunter";
+        return SceneManager.GetActiveScene().name == targetScene;
     }
 }

+ 1 - 1
Assets/DuckHunter/Scripts/GameManager.cs

@@ -45,7 +45,7 @@ namespace DuckHunter
                 StartGame(true);
             }
 
-            UserGameAnalyse1.CreateWhenGameStart();
+            UserGameAnalyse1.CreateWhenGameStart(13);
         }
 
         void Update()

+ 5 - 0
Assets/WildAttack/Scripts/GameEnter.cs

@@ -19,6 +19,11 @@ namespace WildAttack
             ModuleInit();
         }
 
+        void Start()
+        {
+            UserGameAnalyse1.CreateWhenGameStart(14);
+        }
+
         void OnDestroy()
         {
             SingletonManager.Clear();