chenxin
2020-11-18 3283607888bfa1d1a6870fbe00062e4bd9f53ec3
Assets/Scripts/GameAnalytics_SDK/TDAA_SDKManager.cs
@@ -1,9 +1,11 @@
using System.Collections;
using System.Collections.Generic;
using KTGMGemClient;
using UnityEngine;
public class TDAA_SDKManager : MonoBehaviour
{
    //需要在PlayerSetting中添加宏 TDAA_CUSTOM
    private static TDAA_SDKManager _Ins;
    public static TDAA_SDKManager Ins
    {
@@ -41,11 +43,38 @@
        maxLevel = PlayerPrefs.GetInt(maxLevelStr);
        maxWave = PlayerPrefs.GetInt(maxWaveStr);
        AddListener();
    }
    private void AddListener()
    {
        EventCenter.Ins.Add<int, int>((int)KTGMGemClient.EventType.EndlessCompletedPort, EndlessCompletedPort);
        EventCenter.Ins.Add((int)KTGMGemClient.EventType.EndlessLevelCompleted, EndlessLevelCompleted);
    }
    /// <summary>
    /// 无尽模式成功通过第*关,第*波
    /// </summary>
    /// <param name="Level"></param>
    /// <param name="CurrentWaveIndex"></param>
    private void EndlessCompletedPort(int level, int currentWaveIndex)
    {
        MaxWave(level, currentWaveIndex);
        WaveDone(level, currentWaveIndex);
    }
    /// <summary>
    /// 无尽模式完成
    /// </summary>
    private void EndlessLevelCompleted()
    {
        OnUseSkill(GameConfig.EndlessPortUseSkillTowerCount);
        OnOpenTower(GameConfig.EndlessOpenAttackTowerCount);
        OnClickTowerBuyBtn(GameConfig.EndlessBuyTowerCount);
    }
    public void Reset()
    {
        Debug.LogError("清除了数据");
        CommonDebugHelper.Debug("清除了数据");
        //PlayerPrefs.DeleteAll();
        isFirstStart = PlayerPrefs.GetInt(firstStart) == 0;
        statisticsStep = PlayerPrefs.GetInt(statisticsStr);
@@ -133,7 +162,7 @@
        {
            OnRegister();
            Debug.LogError("注册人数统计");
            CommonDebugHelper.Debug("注册人数统计");
            //只记录一次
            Dictionary<string, object> dic = new Dictionary<string, object>
            {
@@ -142,6 +171,7 @@
            OnEvent("注册人数统计", dic);
            isFirstStart = false;
            PlayerPrefs.SetInt(firstStart, 1);
            Statistics(3);//埋点
        }
        Login();
    }
@@ -199,7 +229,7 @@
            // };
            //dic[key] = 1;
            Debug.LogError("漏斗流统计:" + key);
           CommonDebugHelper.Debug("漏斗流统计:" + key);
            OnEvent(key, dic);
            statisticsStep = step;
@@ -217,12 +247,12 @@
    {
        if (step > guideStep)
        {
            Debug.LogError("引导步数统计:" + step);
            CommonDebugHelper.Debug("引导步数统计:" + step);
            Dictionary<string, object> dic = new Dictionary<string, object>
            {
                { "Guide", step.ToString()}
            };
            OnEvent("引导步数统计",  dic);
            OnEvent("引导步数统计", dic);
            guideStep = step;
            PlayerPrefs.SetInt(guideStepStr, step);
@@ -232,56 +262,56 @@
    //5.每次游玩过程中,点击【重新开始】按钮的次数,每次重新开始记做一轮
    public void OnClickRestartBtn()
    {
        Debug.LogError("重新开始按钮次数");
        CommonDebugHelper.Debug("重新开始按钮次数");
        Dictionary<string, object> dic = new Dictionary<string, object>
        {
            { "OnClickRestartBtn", 1}
        };
        OnEvent("重新开始按钮次数",  dic);
        OnEvent("重新开始按钮次数", dic);
    }
    //7.每一轮游戏中成功使用技能宝石的次数
    public void OnUseSkill(int count)
    {
        Debug.LogError("每一轮游戏中成功使用技能宝石的次数:" + count);
        CommonDebugHelper.Debug("每一轮游戏中成功使用技能宝石的次数:" + count);
        Dictionary<string, object> dic = new Dictionary<string, object>
        {
            { "使用次数", count+"次"}
        };
        OnEvent("每一轮游戏中成功使用技能宝石的次数",  dic);
        OnEvent("每一轮游戏中成功使用技能宝石的次数", dic);
    }
    //8.每一轮游戏中成功开启的塔位置数量
    public void OnOpenTower(int towerCount)
    {
        Debug.LogError("每一轮游戏中成功开启的塔位置数量:" + towerCount);
        CommonDebugHelper.Debug("每一轮游戏中成功开启的塔位置数量:" + towerCount);
        Dictionary<string, object> dic = new Dictionary<string, object>
        {
            { "购买次数", towerCount+"次"}
        };
        OnEvent("每一轮游戏中成功开启的塔位置数量",  dic);
        OnEvent("每一轮游戏中成功开启的塔位置数量", dic);
    }
    //9.每一轮游戏中成功购买塔的数量
    public void OnClickTowerBuyBtn(int buyCount)
    {
        Debug.LogError("每一轮游戏中成功购买塔的数量:" + buyCount);
        CommonDebugHelper.Debug("每一轮游戏中成功购买塔的数量:" + buyCount);
        Dictionary<string, object> dic = new Dictionary<string, object>
        {
            { "购买次数", buyCount+"次"}
        };
        OnEvent("每一轮游戏中成功购买塔的数量",  dic);
        OnEvent("每一轮游戏中成功购买塔的数量", dic);
    }
    //10.玩家在结算界面点击【对pvp感兴趣】按钮次数
    public void OnClickPVPBtn()
    {
        Debug.LogError("对pvp感兴趣");
        CommonDebugHelper.Debug("对pvp感兴趣");
        Dictionary<string, object> dic = new Dictionary<string, object>
        {
            { "OnClickPVPBtn", 1}
        };
        OnEvent("对pvp感兴趣",  dic);
        OnEvent("对pvp感兴趣", dic);
    }
@@ -306,12 +336,17 @@
        }
        if (canSend)
        {
            Debug.LogError($"玩家最高打到第{level}关{wave}波");
            maxLevel = level;
            PlayerPrefs.SetInt(maxLevelStr, maxLevel);
            maxWave = wave;
            PlayerPrefs.SetInt(maxWaveStr, maxWave);
            CommonDebugHelper.Debug($"玩家最高打到第{level}关{wave}波");
            Dictionary<string, object> dic = new Dictionary<string, object>
            {
                { "MaxWave", $"第{level}关{wave}波"}
            };
            OnEvent("玩家最高打到第x关y波",dic);
            OnEvent("玩家最高打到第x关y波", dic);
        }
    }
@@ -322,7 +357,7 @@
    /// <param name="wave">第几波</param>
    public void WaveDone(int level, int wave)
    {
        Debug.LogError($"玩家达到第{level}关{wave}波");
        CommonDebugHelper.Debug($"玩家达到第{level}关{wave}波");
        Dictionary<string, object> dic = new Dictionary<string, object>
        {
            { $"第{level}关{wave}波", 1}
@@ -352,7 +387,6 @@
    private void OnDestroy()
    {
        Debug.Log("onDestroy");
        TalkingDataPlugin.SessionStoped();
    }
}