709 lines
		
	
	
		
			28 KiB
		
	
	
	
		
			C#
		
	
	
			
		
		
	
	
			709 lines
		
	
	
		
			28 KiB
		
	
	
	
		
			C#
		
	
	
 | 
						|
 | 
						|
 | 
						|
namespace Guru
 | 
						|
{
 | 
						|
    using System;
 | 
						|
    using System.Collections.Generic;
 | 
						|
    using UnityEngine;
 | 
						|
    
 | 
						|
    /// <summary>
 | 
						|
    /// 打点管理
 | 
						|
    /// </summary>
 | 
						|
    public partial class GuruSDK
 | 
						|
    {
 | 
						|
        /// <summary>
 | 
						|
        /// 主线关卡类型
 | 
						|
        /// 只有传入此类型时才会进行 Blevel 的累加
 | 
						|
        /// </summary>
 | 
						|
        public const string LevelCategoryMain = "main";
 | 
						|
        
 | 
						|
        //----------------- 关卡开始类型 ---------------------
 | 
						|
        public const string EventLevelStartModePlay = "play";
 | 
						|
        public const string EventLevelStartModeReplay = "replay";
 | 
						|
        public const string EventLevelStartModeContinue= "continue";
 | 
						|
        
 | 
						|
        //----------------- 关卡结束类型 ---------------------
 | 
						|
        public const string EventLevelEndSuccess = "success";
 | 
						|
        public const string EventLevelEndFail = "fail";
 | 
						|
        public const string EventLevelEndExit = "exit";
 | 
						|
        public const string EventLevelEndTimeout = "timeout";
 | 
						|
 | 
						|
        #region 通用接口
 | 
						|
        /// <summary>
 | 
						|
        /// 自定义事件打点
 | 
						|
        /// </summary>
 | 
						|
        /// <param name="eventName"></param>
 | 
						|
        /// <param name="data"></param>
 | 
						|
        public static void LogEvent(string eventName, Dictionary<string, dynamic> data = null)
 | 
						|
        {
 | 
						|
            if (!IsInitialSuccess)
 | 
						|
            {
 | 
						|
                Debug.LogError($"{Tag} :: LogEvent {eventName} :: Please call <GuruSDK.Start()> first, before you call <LogEvent>.");
 | 
						|
                return;
 | 
						|
            }
 | 
						|
            Analytics.Track(eventName, data);
 | 
						|
        }
 | 
						|
 | 
						|
        public static void SetScreen(string screen, string extra = "")
 | 
						|
        {
 | 
						|
            if (!IsInitialSuccess)
 | 
						|
            {
 | 
						|
                Debug.LogError($"{Tag} :: SetScreen {screen} :: Please call <GuruSDK.Start()> first, before you call <SetScreen>.");
 | 
						|
                return;
 | 
						|
            }
 | 
						|
            Analytics.SetCurrentScreen(screen, extra);
 | 
						|
        }
 | 
						|
 | 
						|
        #endregion
 | 
						|
        
 | 
						|
        #region 游戏打点
 | 
						|
 | 
						|
        /// <summary>
 | 
						|
        /// 游戏启动打点
 | 
						|
        /// </summary>
 | 
						|
        /// <param name="levelId"></param>
 | 
						|
        /// <param name="levelName"></param>
 | 
						|
        /// <param name="levelCategory"></param>
 | 
						|
        /// <param name="levelID"></param>
 | 
						|
        /// <param name="startType"></param>
 | 
						|
        /// <param name="isReplay"></param>
 | 
						|
        public static void LogLevelStart(int levelId, string startType = EventLevelStartModePlay, 
 | 
						|
            string levelCategory = LevelCategoryMain, string levelName = "", string levelID = "",
 | 
						|
            bool isReplay = false)
 | 
						|
        {
 | 
						|
            if (!IsInitialSuccess)
 | 
						|
            {
 | 
						|
                Debug.LogError($"{Tag} :: LogLevelStart {levelId} :: Please call <GuruSDK.Start()> first, before you call <LogLevelStart>.");
 | 
						|
                return;
 | 
						|
            }
 | 
						|
 | 
						|
            Analytics.LogLevelStart(levelId, levelName, levelCategory, levelID, startType, isReplay);
 | 
						|
        }
 | 
						|
        
 | 
						|
        /// <summary>
 | 
						|
        /// 游戏点击 Continue 重开始游戏
 | 
						|
        /// </summary>
 | 
						|
        /// <param name="levelId"></param>
 | 
						|
        /// <param name="levelCategory"></param>
 | 
						|
        /// <param name="levelName"></param>
 | 
						|
        /// <param name="levelID"></param>
 | 
						|
        public static void LogLevelContinue(int levelId, string levelCategory = LevelCategoryMain,
 | 
						|
            string levelName = "", string levelID = "")
 | 
						|
        {
 | 
						|
            LogLevelStart(levelId, EventLevelStartModeContinue, levelCategory, levelName, levelID,  true);
 | 
						|
        }
 | 
						|
        
 | 
						|
        /// <summary>
 | 
						|
        /// 游戏点击 Continue 重开始游戏
 | 
						|
        /// </summary>
 | 
						|
        /// <param name="levelId"></param>
 | 
						|
        /// <param name="levelCategory"></param>
 | 
						|
        /// <param name="levelName"></param>
 | 
						|
        /// <param name="levelID"></param>
 | 
						|
        public static void LogLevelReplay(int levelId, string levelCategory = LevelCategoryMain,
 | 
						|
            string levelName = "", string levelID = "")
 | 
						|
        {
 | 
						|
            LogLevelStart(levelId, EventLevelStartModeReplay,levelCategory, levelName, levelID,  true);
 | 
						|
        }
 | 
						|
        
 | 
						|
        /// <summary>
 | 
						|
        /// 游戏胜利打点
 | 
						|
        /// </summary>
 | 
						|
        public static void LogLevelEnd(int levelId,  string result = EventLevelEndSuccess,
 | 
						|
            string levelCategory = LevelCategoryMain, string levelName = "", string levelID = "",
 | 
						|
            int? duration = null, int? step = null, int? score = null )
 | 
						|
        {
 | 
						|
            if (!IsInitialSuccess)
 | 
						|
            {
 | 
						|
                Debug.LogError($"{Tag} :: LogLevelEnd {levelId} :: Please call <GuruSDK.Start()> first, before you call <LogLevelEnd>.");
 | 
						|
                return;
 | 
						|
            }
 | 
						|
            
 | 
						|
            if (InitConfig.AutoRecordFinishedLevels)
 | 
						|
            {
 | 
						|
                if(result == EventLevelEndSuccess){
 | 
						|
                    if(levelCategory == LevelCategoryMain)
 | 
						|
                    {
 | 
						|
                        if (levelId > Model.SuccessLevelId) Model.SuccessLevelId = levelId; // 自动记录关卡完成次数
 | 
						|
                    }
 | 
						|
                    Model.TotalPlayedCount++; // 自动记录关卡总次数
 | 
						|
                }
 | 
						|
                
 | 
						|
 | 
						|
                Analytics.BLevel = Model.SuccessLevelId; // 记录 BLevel
 | 
						|
                Analytics.BPlay = Model.TotalPlayedCount; // 记录 BPlay
 | 
						|
            }
 | 
						|
            
 | 
						|
            Analytics.LogLevelEnd(levelId, result, levelName, levelCategory, levelID, duration, step, score);
 | 
						|
        }
 | 
						|
        
 | 
						|
        
 | 
						|
        /// <summary>
 | 
						|
        /// 游戏失败打点
 | 
						|
        /// 需要为游戏记录详细的失败原因
 | 
						|
        /// </summary>
 | 
						|
        public static void LogLevelFail(int levelId,
 | 
						|
            string levelCategory = LevelCategoryMain, string levelName = "", string levelID = "",
 | 
						|
            int? duration = null, int? step = null, int? score = null )
 | 
						|
        {
 | 
						|
            LogLevelEnd(levelId, EventLevelEndFail, levelCategory, levelName, levelID, duration, step, score);
 | 
						|
        }
 | 
						|
 | 
						|
        /// <summary>
 | 
						|
        /// 因退出关卡导致游戏失败
 | 
						|
        /// </summary>
 | 
						|
        public static void LogLevelFailExit(int levelId,
 | 
						|
            string levelCategory = LevelCategoryMain, string levelName = "", string levelID = "",
 | 
						|
            int? duration = null, int? step = null, int? score = null)
 | 
						|
        {
 | 
						|
            LogLevelEnd(levelId, EventLevelEndExit, levelCategory, levelName, levelID, duration, step, score);
 | 
						|
        }
 | 
						|
 | 
						|
        /// <summary>
 | 
						|
        /// 因关卡超时导致游戏失败
 | 
						|
        /// </summary>
 | 
						|
        public static void LogLevelFailTimeout(int levelId,
 | 
						|
            string levelCategory = LevelCategoryMain, string levelName = "", string levelID = "",
 | 
						|
            int? duration = null, int? step = null, int? score = null)
 | 
						|
        {
 | 
						|
            LogLevelEnd(levelId, EventLevelEndTimeout, levelCategory, levelName, levelID, duration, step, score);
 | 
						|
        }
 | 
						|
 | 
						|
 | 
						|
        /// <summary>
 | 
						|
        /// 玩家(角色)升级事件
 | 
						|
        /// </summary>
 | 
						|
        /// <param name="playerLevel"></param>
 | 
						|
        /// <param name="playerName"></param>
 | 
						|
        public static void LogLevelUp(int playerLevel, string playerName)
 | 
						|
        {
 | 
						|
            if (!IsInitialSuccess)
 | 
						|
            {
 | 
						|
                Debug.LogError($"{Tag} :: LogLevelUp {playerLevel} :: Please call <GuruSDK.Start()> first, before you call <LogLevelUp>.");
 | 
						|
                return;
 | 
						|
            }
 | 
						|
            Analytics.LevelUp(playerLevel, playerName);
 | 
						|
        }
 | 
						|
 | 
						|
        /// <summary>
 | 
						|
        /// 玩家解锁成就
 | 
						|
        /// </summary>
 | 
						|
        /// <param name="achievementName"></param>
 | 
						|
        public static void LogAchievement(string achievementName)
 | 
						|
        {
 | 
						|
            if (!IsInitialSuccess)
 | 
						|
            {
 | 
						|
                Debug.LogError($"{Tag} :: LogAchievement {achievementName} :: Please call <GuruSDK.Start()> first, before you call <LogAchievement>.");
 | 
						|
                return;
 | 
						|
            }
 | 
						|
            Analytics.UnlockAchievement(achievementName);
 | 
						|
        }
 | 
						|
        
 | 
						|
        #endregion
 | 
						|
 | 
						|
        #region 用户属性
 | 
						|
 | 
						|
        /// <summary>
 | 
						|
        /// 提前调用用户属性
 | 
						|
        /// </summary>
 | 
						|
        private static void InitUserProperties()
 | 
						|
        {
 | 
						|
            if (!IsInitialSuccess)
 | 
						|
            {
 | 
						|
                Debug.LogError($"{Tag} :: InitUserProperties :: Please call <GuruSDK.Start()> first, before you call <InitUserProperties>.");
 | 
						|
                return;
 | 
						|
            }
 | 
						|
            
 | 
						|
            SetUserIsIAP(Model.IsIAPUser); // 预先设置用户的 IAP User 属性
 | 
						|
            SetUserBLevel(Model.SuccessLevelId); // 预先设置用户的 BLevel 属性
 | 
						|
            SetUserBPlay(Model.TotalPlayedCount);  // 预先设置用户的 BPlay 属性
 | 
						|
        }
 | 
						|
 | 
						|
 | 
						|
 | 
						|
        /// <summary>
 | 
						|
        /// 设置用户属性
 | 
						|
        /// </summary>
 | 
						|
        /// <param name="key"></param>
 | 
						|
        /// <param name="value"></param>
 | 
						|
        public static void SetUserProperty(string key, string value)
 | 
						|
        {
 | 
						|
            if (!IsInitialSuccess)
 | 
						|
            {
 | 
						|
                Debug.LogError($"{Tag} :: SetUserProperty {key}:{value} ::Please call <GuruSDK.Start()> first, before you call <SetUserProperty>.");
 | 
						|
                return;
 | 
						|
            }
 | 
						|
            Analytics.SetUserProperty(key, value);
 | 
						|
        }
 | 
						|
 | 
						|
        public static void SetUID(string uid)
 | 
						|
        {
 | 
						|
            SetUserProperty(Analytics.PropertyUserID, uid);
 | 
						|
        }
 | 
						|
 | 
						|
        public static void SetUserBLevel(int blevel)
 | 
						|
        {
 | 
						|
            SetUserProperty(Analytics.PropertyLevel, $"{blevel}");
 | 
						|
        }
 | 
						|
        
 | 
						|
        public static void SetUserBPlay(int bplay)
 | 
						|
        {
 | 
						|
            SetUserProperty(Analytics.PropertyPlay, $"{bplay}");
 | 
						|
        }
 | 
						|
 | 
						|
        public static void SetUserTotalCoins(int totalCoins)
 | 
						|
        {
 | 
						|
            SetUserProperty(Analytics.PropertyCoin, $"{totalCoins}");        
 | 
						|
        }
 | 
						|
        
 | 
						|
        public static void SetUserCoins(int coins)
 | 
						|
        {
 | 
						|
            SetUserProperty(Analytics.PropertyNonIAPCoin, $"{coins}");        
 | 
						|
        }
 | 
						|
        
 | 
						|
        public static void SetUserPaidCoins(int paidCoins)
 | 
						|
        {
 | 
						|
            SetUserProperty(Analytics.PropertyIAPCoin, $"{paidCoins}");        
 | 
						|
        }
 | 
						|
        
 | 
						|
        public static void SetUserExp(int exp)
 | 
						|
        {
 | 
						|
            SetUserProperty(Analytics.PropertyExp, $"{exp}");        
 | 
						|
        }
 | 
						|
        
 | 
						|
        public static void SetUserHp(int hp)
 | 
						|
        {
 | 
						|
            SetUserProperty(Analytics.PropertyHp, $"{hp}");        
 | 
						|
        }
 | 
						|
 | 
						|
        public static void SetUserGrade(int grade)
 | 
						|
        {
 | 
						|
            SetUserProperty(Analytics.PropertyGrade, $"{grade}");        
 | 
						|
        }
 | 
						|
 | 
						|
        public static void SetUserIsIAP(bool isIapUser)
 | 
						|
        {
 | 
						|
            SetUserProperty(Analytics.PropertyIsIAPUser, isIapUser? "true" : "false");
 | 
						|
        }
 | 
						|
 | 
						|
        #endregion
 | 
						|
 | 
						|
        #region SDK 打点
 | 
						|
        
 | 
						|
        /// <summary>
 | 
						|
        /// Log SDK boost time
 | 
						|
        /// </summary>
 | 
						|
        /// <param name="time"></param>
 | 
						|
        private static void LogSDKInitTime(double time)
 | 
						|
        {
 | 
						|
            Analytics.Track(Consts.EventSDKInfo, new Dictionary<string, dynamic>()
 | 
						|
            {
 | 
						|
                { Consts.PropertyFirstOpenTime, time.ToString("F6") },
 | 
						|
                { Consts.PropertyDeviceID, DeviceId },
 | 
						|
            }, new Analytics.EventSetting()
 | 
						|
            {
 | 
						|
                EnableFirebaseAnalytics = true,
 | 
						|
            });
 | 
						|
        }
 | 
						|
 | 
						|
        private static void LogFirebaseDeps(bool success)
 | 
						|
        {
 | 
						|
            Analytics.Track(Consts.EventSDKInfo, new Dictionary<string, dynamic>()
 | 
						|
            {
 | 
						|
                { Consts.ParameterItemName, $"fbs_done_{(success ? "true" : "false")}" },
 | 
						|
            }, new Analytics.EventSetting()
 | 
						|
            {
 | 
						|
                EnableFirebaseAnalytics = true,
 | 
						|
            });
 | 
						|
        }
 | 
						|
 | 
						|
        #endregion
 | 
						|
 | 
						|
        #region 经济打点
 | 
						|
        
 | 
						|
        // ************************************************************************************************
 | 
						|
        // *
 | 
						|
        // *                                        经济打点
 | 
						|
        // * 内容详参: https://docs.google.com/spreadsheets/d/1xYSsAjbrwqeJm7panoVzHO0PeGRQVDCR4e2CU9OPEzk/edit#gid=0
 | 
						|
        // *
 | 
						|
        // ************************************************************************************************
 | 
						|
        
 | 
						|
        //---------------------------------------- EARN ---------------------------------------- 
 | 
						|
        /// <summary>
 | 
						|
        /// 获取虚拟货币/道具. 
 | 
						|
        /// 基础接口, 不推荐项目组直接调用
 | 
						|
        /// 请直接调用其他对应场景的统计接口
 | 
						|
        /// </summary>
 | 
						|
        /// <param name="currencyName"></param>
 | 
						|
        /// <param name="value"></param>
 | 
						|
        /// <param name="balance"></param>
 | 
						|
        /// <param name="category"></param>
 | 
						|
        /// <param name="levelName"></param>
 | 
						|
        /// <param name="itemName"></param>
 | 
						|
        /// <param name="scene"></param>
 | 
						|
        public static void EarnVirtualCurrency(string currencyName, 
 | 
						|
            int value, int balance, 
 | 
						|
            string category = "", string itemName = "",
 | 
						|
            string levelName = "", string scene = "")
 | 
						|
        {
 | 
						|
            Analytics.EarnVirtualCurrency(currencyName, value, balance, category, itemName,levelName,  scene);
 | 
						|
        }
 | 
						|
        
 | 
						|
        
 | 
						|
        
 | 
						|
        /// <summary>
 | 
						|
        /// 赚取组合: 货币+道具
 | 
						|
        /// </summary>
 | 
						|
        /// <param name="currencyName"></param>
 | 
						|
        /// <param name="value"></param>
 | 
						|
        /// <param name="balance"></param>
 | 
						|
        /// <param name="category"></param>
 | 
						|
        /// <param name="itemName"></param>
 | 
						|
        /// <param name="props"></param>
 | 
						|
        /// <param name="levelName"></param>
 | 
						|
        /// <param name="scene"></param>
 | 
						|
        private static void EarnVirtualCurrencyAndProps(string currencyName, 
 | 
						|
            int value = 0, int balance = 0,
 | 
						|
            string category = "", string itemName = "",
 | 
						|
            string levelName = "", string scene = Consts.ParameterDefaultScene,  
 | 
						|
            string[] props = null)
 | 
						|
        {
 | 
						|
            //---- Currency -----
 | 
						|
            if (value > 0)
 | 
						|
            {
 | 
						|
                EarnVirtualCurrency(currencyName, value, balance, category, itemName, levelName,  scene);
 | 
						|
            }
 | 
						|
            //---- Props --------
 | 
						|
            if (null != props)
 | 
						|
            {
 | 
						|
                int i = 0;
 | 
						|
                while (i < props.Length)
 | 
						|
                {
 | 
						|
                    EarnVirtualCurrency(props[i], 1, 0, category, itemName, levelName, scene);
 | 
						|
                    i++;
 | 
						|
                }
 | 
						|
            }
 | 
						|
        }
 | 
						|
 | 
						|
        /// <summary>
 | 
						|
        /// 签到奖励. 获得货币/道具
 | 
						|
        /// <li>通常类型: Coin 收入 </li>
 | 
						|
        /// <li>特殊类型: Coin + Props (道具列表) </li>
 | 
						|
        /// <li>特殊类型: Props (道具列表) </li>
 | 
						|
        /// </summary>
 | 
						|
        /// <param name="currencyName">货币名称</param>
 | 
						|
        /// <param name="value">赚取金额</param>
 | 
						|
        /// <param name="balance">货币总量(累加后)</param>
 | 
						|
        /// <param name="levelName">当前关卡名称</param>
 | 
						|
        /// <param name="scene">应用场景</param>
 | 
						|
        /// <param name="props">获取的道具名称列表</param>
 | 
						|
        public static void EarnVirtualCurrencyBySign(string currencyName, 
 | 
						|
            int value = 0, int balance = 0, string levelName = "", 
 | 
						|
            string scene = "home", string[] props = null)
 | 
						|
        {
 | 
						|
            string category = Consts.CurrencyCategoryReward;
 | 
						|
            string itemName = "sign";
 | 
						|
            
 | 
						|
            EarnVirtualCurrencyAndProps(currencyName, value, balance, category, itemName, levelName, scene, props);
 | 
						|
        }
 | 
						|
 | 
						|
 | 
						|
        /// <summary>
 | 
						|
        /// IAP 付费购买. 获得货币/道具
 | 
						|
        /// <li>通常类型: Coin 收入 </li>
 | 
						|
        /// <li>特殊类型: Coin + Props (道具列表) </li>
 | 
						|
        /// <li>特殊类型: Props (道具列表) </li> 
 | 
						|
        /// </summary>
 | 
						|
        /// <param name="currencyName">IAP 道具名称</param>
 | 
						|
        /// <param name="productId">IAP 道具商品 ID </param>
 | 
						|
        /// <param name="value">赚取金额</param>
 | 
						|
        /// <param name="balance">货币总量(累加后)</param>
 | 
						|
        /// <param name="levelName">当前关卡名称</param>
 | 
						|
        /// <param name="scene">应用场景</param>
 | 
						|
        /// <param name="props">获取的道具名称列表</param>
 | 
						|
        public static void EarnVirtualCurrencyByIAP(string currencyName, string productId, 
 | 
						|
            int value = 0, int balance = 0, string levelName = "", 
 | 
						|
            string scene = "store", string[] props = null)
 | 
						|
        {
 | 
						|
            string category = Consts.CurrencyCategoryIAP;
 | 
						|
            string itemName = productId;
 | 
						|
            EarnVirtualCurrencyAndProps(currencyName, value, balance, category, itemName, levelName, scene, props);
 | 
						|
        }
 | 
						|
 | 
						|
        /// <summary>
 | 
						|
        /// 看广告获取到货币/道具
 | 
						|
        /// <li>通常类型: Coin 收入 </li>
 | 
						|
        /// <li>特殊类型: Coin + Props (道具列表) </li>
 | 
						|
        /// <li>特殊类型: Props (道具列表) </li> 
 | 
						|
        /// </summary>
 | 
						|
        /// <param name="currencyName">货币名称</param>
 | 
						|
        /// <param name="value">赚取金额</param>
 | 
						|
        /// <param name="balance">货币总量(累加后)</param>
 | 
						|
        /// <param name="levelName">当前关卡名称</param>
 | 
						|
        /// <param name="scene">应用场景</param>
 | 
						|
        /// <param name="props">获取的道具名称列表</param>
 | 
						|
        public static void EarnVirtualCurrencyByAds(string currencyName, 
 | 
						|
            int value = 0, int balance = 0, string levelName = "", 
 | 
						|
            string scene = "store", string[] props = null)
 | 
						|
        {
 | 
						|
            string category = Consts.CurrencyCategoryReward;
 | 
						|
            string itemName = "ads";
 | 
						|
            EarnVirtualCurrencyAndProps(currencyName, value, balance, category, itemName, levelName, scene, props);
 | 
						|
        }
 | 
						|
        
 | 
						|
        /// <summary>
 | 
						|
        /// 使用了金币半价 + 看广告获取到货币/道具
 | 
						|
        /// <li>通常类型: Coin 收入 </li>
 | 
						|
        /// <li>特殊类型: Coin + Props (道具列表) </li>
 | 
						|
        /// <li>特殊类型: Props (道具列表) </li> 
 | 
						|
        /// </summary>
 | 
						|
        /// <param name="currencyName">货币名称</param>
 | 
						|
        /// <param name="value">赚取金额</param>
 | 
						|
        /// <param name="balance">货币总量(累加后)</param>
 | 
						|
        /// <param name="levelName">当前关卡名称</param>
 | 
						|
        /// <param name="scene">应用场景</param>
 | 
						|
        /// <param name="props">获取的道具名称列表</param>
 | 
						|
        public static void EarnVirtualCurrencyByPaidAds(string currencyName, 
 | 
						|
            int value = 0, int balance = 0, string levelName = "", 
 | 
						|
            string scene = Consts.ParameterDefaultScene, string[] props = null)
 | 
						|
        {
 | 
						|
            string category = Consts.CurrencyCategoryBonus;
 | 
						|
            string itemName = "ads";
 | 
						|
            EarnVirtualCurrencyAndProps(currencyName, value, balance, category, itemName, levelName, scene, props);
 | 
						|
        }
 | 
						|
 | 
						|
        /// <summary>
 | 
						|
        /// 过关奖励获取到货币/道具
 | 
						|
        /// <li>通常类型: Coin 收入 </li>
 | 
						|
        /// <li>特殊类型: Coin + Props (道具列表) </li>
 | 
						|
        /// <li>特殊类型: Props (道具列表) </li> 
 | 
						|
        /// </summary>
 | 
						|
        /// <param name="currencyName">货币名称</param>
 | 
						|
        /// <param name="value">赚取金额</param>
 | 
						|
        /// <param name="balance">货币总量(累加后)</param>
 | 
						|
        /// <param name="levelName">当前关卡名称</param>
 | 
						|
        /// <param name="scene">应用场景</param>
 | 
						|
        /// <param name="props">获取的道具名称列表</param>
 | 
						|
        public static void EarnVirtualCurrencyByLevelComplete(string currencyName, 
 | 
						|
            int value = 0, int balance = 0, string levelName = "", 
 | 
						|
            string scene = "store", string[] props = null)
 | 
						|
        {
 | 
						|
            string category = Consts.CurrencyCategoryReward;
 | 
						|
            string itemName = "level";
 | 
						|
            EarnVirtualCurrencyAndProps(currencyName, value, balance, category, itemName, levelName, scene, props);
 | 
						|
        }
 | 
						|
 | 
						|
 | 
						|
        /// <summary>
 | 
						|
        /// 通过使用 Currency 购买获得 Prop (记录 Prop 增加的打点, 消费游戏内货币)
 | 
						|
        /// </summary>
 | 
						|
        /// <param name="currencyName">货币名称</param>
 | 
						|
        /// <param name="props">获取的道具名称列表</param>
 | 
						|
        /// <param name="scene">应用场景</param>
 | 
						|
        /// <param name="value">赚取金额</param>
 | 
						|
        /// <param name="balance">货币总量(累加后)</param>
 | 
						|
        /// <param name="levelName">当前关卡名称</param>
 | 
						|
        public static void EarnPropsByVirtualCurrency(string currencyName, string[] props,
 | 
						|
            string scene = Consts.ParameterDefaultScene,
 | 
						|
            int value = 1, int balance = 0, string levelName = "")
 | 
						|
        {
 | 
						|
            string category = Consts.CurrencyCategoryIGC;
 | 
						|
            string itemName = currencyName;
 | 
						|
            EarnVirtualCurrencyAndProps(currencyName, value, balance, category, itemName, levelName, scene, props);
 | 
						|
        }
 | 
						|
        
 | 
						|
        /// <summary>
 | 
						|
        /// 通过道具交换/合成或得了其他道具
 | 
						|
        /// </summary>
 | 
						|
        /// <param name="propName"></param>
 | 
						|
        /// <param name="otherName"></param>
 | 
						|
        /// <param name="scene"></param>
 | 
						|
        /// <param name="value"></param>
 | 
						|
        /// <param name="balance"></param>
 | 
						|
        /// <param name="levelName"></param>
 | 
						|
        public static void EarnPropByProp(string propName, string otherName,
 | 
						|
            string scene = Consts.ParameterDefaultScene,
 | 
						|
            int value = 1, int balance = 0, string levelName = "")
 | 
						|
        {
 | 
						|
            string category = Consts.CurrencyCategoryIGB;
 | 
						|
            EarnVirtualCurrency(propName, value, balance, category, otherName, levelName, scene);
 | 
						|
        }
 | 
						|
        
 | 
						|
        
 | 
						|
        /// <summary>
 | 
						|
        /// 通过转盘或者抽奖, 获取货币/道具
 | 
						|
        /// <li>通常类型: Coin 收入 </li>
 | 
						|
        /// <li>特殊类型: Coin + Props (道具列表) </li>
 | 
						|
        /// <li>特殊类型: Props (道具列表) </li> 
 | 
						|
        /// </summary>
 | 
						|
        /// <param name="currencyName">货币名称</param>
 | 
						|
        /// <param name="value">赚取金额</param>
 | 
						|
        /// <param name="balance">货币总量(累加后)</param>
 | 
						|
        /// <param name="levelName">当前关卡名称</param>
 | 
						|
        /// <param name="scene">应用场景</param>
 | 
						|
        /// <param name="props">获取的道具名称列表</param>
 | 
						|
        public static void EarnVirtualCurrencyByLottery(string currencyName, 
 | 
						|
            int value = 0, int balance = 0, string levelName = "", 
 | 
						|
            string scene = "store", string[] props = null)
 | 
						|
        {
 | 
						|
            string category = Consts.CurrencyCategoryIGB;
 | 
						|
            string itemName = "lottery";
 | 
						|
            EarnVirtualCurrencyAndProps(currencyName, value, balance, category, itemName, levelName, scene, props);
 | 
						|
        }
 | 
						|
        
 | 
						|
        
 | 
						|
        //---------------------------------------- EARN ---------------------------------------- 
 | 
						|
 | 
						|
 | 
						|
        /// <summary>
 | 
						|
        /// 花费虚拟货币/道具
 | 
						|
        /// 基础接口, 不推荐项目组直接调用
 | 
						|
        /// 请直接调用其他对应场景的统计接口
 | 
						|
        /// </summary>
 | 
						|
        /// <param name="currencyName"></param>
 | 
						|
        /// <param name="value"></param>
 | 
						|
        /// <param name="balance"></param>
 | 
						|
        /// <param name="category"></param>
 | 
						|
        /// <param name="itemName"></param>
 | 
						|
        /// <param name="levelName"></param>
 | 
						|
        /// <param name="scene"></param>
 | 
						|
        public static void SpendVirtualCurrency(string currencyName, 
 | 
						|
            int value, int balance, 
 | 
						|
            string category = "", string itemName = "",
 | 
						|
            string levelName = "", string scene = "")
 | 
						|
        {
 | 
						|
            Analytics.SpendVirtualCurrency(currencyName, value, balance, category, itemName, levelName, scene);
 | 
						|
        }
 | 
						|
 | 
						|
 | 
						|
        /// <summary>
 | 
						|
        /// 消耗货币购买道具
 | 
						|
        /// </summary>
 | 
						|
        /// <param name="currencyName"></param>
 | 
						|
        /// <param name="prop"></param>
 | 
						|
        /// <param name="value"></param>
 | 
						|
        /// <param name="balance"></param>
 | 
						|
        /// <param name="levelName"></param>
 | 
						|
        /// <param name="scene"></param>
 | 
						|
        public static void SpendVirtualCurrencyWithProp(string currencyName, string prop,
 | 
						|
            int value, int balance,
 | 
						|
            string levelName = "", string scene = "")
 | 
						|
        {
 | 
						|
            SpendVirtualCurrencyWithProps(currencyName, new string[] {prop}, value, balance, levelName, scene);
 | 
						|
        }
 | 
						|
 | 
						|
        /// <summary>
 | 
						|
        /// 消耗货币购买道具 (含多个)
 | 
						|
        /// </summary>
 | 
						|
        /// <param name="currencyName"></param>
 | 
						|
        /// <param name="props"></param>
 | 
						|
        /// <param name="value"></param>
 | 
						|
        /// <param name="balance"></param>
 | 
						|
        /// <param name="levelName"></param>
 | 
						|
        /// <param name="scene"></param>
 | 
						|
        public static void SpendVirtualCurrencyWithProps(string currencyName, string[] props,
 | 
						|
            int value, int balance, 
 | 
						|
            string levelName = "", string scene = "")
 | 
						|
        {
 | 
						|
            string category = Consts.CurrencyCategoryProp;
 | 
						|
            if (props != null && props.Length > 0)
 | 
						|
            {
 | 
						|
                int i = 0;
 | 
						|
                while (i < props.Length)
 | 
						|
                {
 | 
						|
                    SpendVirtualCurrency(currencyName, value, balance, category, props[i], levelName, scene); 
 | 
						|
                    i++;
 | 
						|
                }
 | 
						|
            }
 | 
						|
        }
 | 
						|
 | 
						|
        /// <summary>
 | 
						|
        /// 消耗货币购买礼包或组合
 | 
						|
        /// </summary>
 | 
						|
        /// <param name="currencyName"></param>
 | 
						|
        /// <param name="bundle"></param>
 | 
						|
        /// <param name="value"></param>
 | 
						|
        /// <param name="balance"></param>
 | 
						|
        /// <param name="levelName"></param>
 | 
						|
        /// <param name="scene"></param>
 | 
						|
        public static void SpendVirtualCurrencyWithBundle(string currencyName, string bundle,
 | 
						|
            int value, int balance,
 | 
						|
            string levelName = "", string scene = "")
 | 
						|
        {
 | 
						|
            SpendVirtualCurrencyWithBundles(currencyName, new string[] {bundle}, value, balance, levelName, scene);
 | 
						|
        }
 | 
						|
 | 
						|
        /// <summary>
 | 
						|
        /// 消耗货币购买礼包或组合  (含多个)
 | 
						|
        /// </summary>
 | 
						|
        /// <param name="currencyName"></param>
 | 
						|
        /// <param name="bundles"></param>
 | 
						|
        /// <param name="value"></param>
 | 
						|
        /// <param name="balance"></param>
 | 
						|
        /// <param name="levelName"></param>
 | 
						|
        /// <param name="scene"></param>
 | 
						|
        public static void SpendVirtualCurrencyWithBundles(string currencyName, string[] bundles,
 | 
						|
            int value, int balance, 
 | 
						|
            string levelName = "", string scene = "")
 | 
						|
        {
 | 
						|
            string category = Consts.CurrencyCategoryBundle;
 | 
						|
            if (bundles != null && bundles.Length > 0)
 | 
						|
            {
 | 
						|
                int i = 0;
 | 
						|
                while (i < bundles.Length)
 | 
						|
                {
 | 
						|
                    SpendVirtualCurrency(currencyName, value, balance, category, bundles[i], levelName, scene); 
 | 
						|
                    i++;
 | 
						|
                }
 | 
						|
            }
 | 
						|
        }
 | 
						|
        
 | 
						|
        /// <summary>
 | 
						|
        /// 消耗物品, 交换其他物品
 | 
						|
        /// </summary>
 | 
						|
        /// <param name="currencyName"></param>
 | 
						|
        /// <param name="bundles"></param>
 | 
						|
        /// <param name="value"></param>
 | 
						|
        /// <param name="balance"></param>
 | 
						|
        /// <param name="levelName"></param>
 | 
						|
        /// <param name="scene"></param>
 | 
						|
        public static void SpendPropWithProp(string propName, string otherName,
 | 
						|
            int value, int balance, 
 | 
						|
            string levelName = "", string scene = "", string extraCategory = "")
 | 
						|
        {
 | 
						|
            string category = string.IsNullOrEmpty(extraCategory) ? Consts.CurrencyCategoryProp : extraCategory;
 | 
						|
            SpendVirtualCurrency(propName, value, balance, category, otherName, levelName, scene); 
 | 
						|
        }
 | 
						|
 | 
						|
 | 
						|
        #endregion
 | 
						|
 | 
						|
        #region Crashlytics 接口
 | 
						|
 | 
						|
        public static void CrashLog(string message)
 | 
						|
        {
 | 
						|
            if (!IsFirebaseReady) return;
 | 
						|
            CrashlyticsAgent.Log(message);
 | 
						|
        }
 | 
						|
        
 | 
						|
        public static void CrashException(string message)
 | 
						|
        {
 | 
						|
            if (!IsFirebaseReady) return;
 | 
						|
            CrashlyticsAgent.LogException(message);
 | 
						|
        }
 | 
						|
 | 
						|
        public static void CrashException(Exception ex)
 | 
						|
        {
 | 
						|
            if (!IsFirebaseReady) return;
 | 
						|
            CrashlyticsAgent.LogException(ex);
 | 
						|
        }
 | 
						|
 | 
						|
        public static void CrashCustomKeys(string key, string value)
 | 
						|
        {
 | 
						|
            if (!IsFirebaseReady) return;
 | 
						|
            CrashlyticsAgent.SetCustomKey(key, value);
 | 
						|
        }
 | 
						|
        #endregion
 | 
						|
    }
 | 
						|
} |