|
|
@@ -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;
|
|
|
}
|
|
|
}
|