2023-12-26 03:40:48 +00:00
|
|
|
|
|
2024-03-20 07:40:22 +00:00
|
|
|
|
|
|
|
|
|
|
|
2023-12-26 03:40:48 +00:00
|
|
|
|
namespace Guru
|
|
|
|
|
|
{
|
2024-03-20 07:40:22 +00:00
|
|
|
|
using System;
|
2023-12-26 03:40:48 +00:00
|
|
|
|
using System.Collections.Generic;
|
2024-01-08 02:22:56 +00:00
|
|
|
|
using UnityEngine;
|
2023-12-26 03:40:48 +00:00
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 打点管理
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public partial class GuruSDK
|
|
|
|
|
|
{
|
2024-01-23 09:15:40 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 主线关卡类型
|
|
|
|
|
|
/// 只有传入此类型时才会进行 Blevel 的累加
|
|
|
|
|
|
/// </summary>
|
2024-05-13 09:20:45 +00:00
|
|
|
|
public const string LevelTypeMain = "main";
|
2024-01-23 09:15:40 +00:00
|
|
|
|
|
2023-12-26 03:40:48 +00:00
|
|
|
|
//----------------- 关卡开始类型 ---------------------
|
|
|
|
|
|
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)
|
2024-01-08 03:31:58 +00:00
|
|
|
|
{
|
|
|
|
|
|
if (!IsInitialSuccess)
|
|
|
|
|
|
{
|
2024-05-07 12:37:57 +00:00
|
|
|
|
UnityEngine.Debug.LogError($"{Tag} :: LogEvent {eventName} :: Please call <GuruSDK.Start()> first, before you call <LogEvent>.");
|
2024-01-08 03:31:58 +00:00
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
Analytics.Track(eventName, data);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static void SetScreen(string screen, string extra = "")
|
|
|
|
|
|
{
|
|
|
|
|
|
if (!IsInitialSuccess)
|
|
|
|
|
|
{
|
2024-05-07 12:37:57 +00:00
|
|
|
|
UnityEngine.Debug.LogError($"{Tag} :: SetScreen {screen} :: Please call <GuruSDK.Start()> first, before you call <SetScreen>.");
|
2024-01-08 03:31:58 +00:00
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
Analytics.SetCurrentScreen(screen, extra);
|
|
|
|
|
|
}
|
2023-12-26 03:40:48 +00:00
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
#region 游戏打点
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 游戏启动打点
|
|
|
|
|
|
/// </summary>
|
2024-05-15 01:58:22 +00:00
|
|
|
|
/// <param name="levelId">关卡Id</param>
|
|
|
|
|
|
/// <param name="levelName">关卡名称: main_01_9001, daily_challenge_81011</param>
|
|
|
|
|
|
/// <param name="levelType">关卡类型: 主线:main</param>
|
|
|
|
|
|
/// <param name="puzzleId">配置/谜题/图片/自定义Id: 101120</param>
|
|
|
|
|
|
/// <param name="startType">关卡开始类型: play:开始游戏;replay:重玩;continue:继续游戏</param>
|
|
|
|
|
|
/// <param name="isReplay">是否重新开始: true/false</param>
|
|
|
|
|
|
/// <param name="extra">扩展数据</param>
|
2024-04-02 07:27:34 +00:00
|
|
|
|
public static void LogLevelStart(int levelId, string startType = EventLevelStartModePlay,
|
2024-05-14 01:54:53 +00:00
|
|
|
|
string levelType = LevelTypeMain, string levelName = "", string puzzleId = "",
|
2024-05-11 06:19:11 +00:00
|
|
|
|
bool isReplay = false, Dictionary<string, object> extra = null)
|
2023-12-26 03:40:48 +00:00
|
|
|
|
{
|
2024-01-08 02:22:56 +00:00
|
|
|
|
if (!IsInitialSuccess)
|
|
|
|
|
|
{
|
2024-05-07 12:37:57 +00:00
|
|
|
|
UnityEngine.Debug.LogError($"{Tag} :: LogLevelStart {levelId} :: Please call <GuruSDK.Start()> first, before you call <LogLevelStart>.");
|
2024-01-08 02:22:56 +00:00
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-05-14 01:54:53 +00:00
|
|
|
|
Analytics.LogLevelStart(levelId, levelName, levelType, puzzleId, startType, isReplay, extra);
|
2023-12-26 03:40:48 +00:00
|
|
|
|
}
|
2024-05-11 06:19:11 +00:00
|
|
|
|
|
2023-12-26 03:40:48 +00:00
|
|
|
|
/// <summary>
|
2024-05-15 01:58:22 +00:00
|
|
|
|
/// 游戏点击 Continue 继续游戏
|
2023-12-26 03:40:48 +00:00
|
|
|
|
/// </summary>
|
2024-04-02 07:27:34 +00:00
|
|
|
|
/// <param name="levelId"></param>
|
2024-05-13 09:20:45 +00:00
|
|
|
|
/// <param name="levelType"></param>
|
2023-12-26 03:40:48 +00:00
|
|
|
|
/// <param name="levelName"></param>
|
2024-05-14 01:54:53 +00:00
|
|
|
|
/// <param name="puzzleId"></param>
|
2024-05-11 06:19:11 +00:00
|
|
|
|
/// <param name="extra"></param>
|
2024-05-13 09:20:45 +00:00
|
|
|
|
public static void LogLevelContinue(int levelId, string levelType = LevelTypeMain,
|
2024-05-14 01:54:53 +00:00
|
|
|
|
string levelName = "", string puzzleId = "", Dictionary<string, object> extra = null)
|
2023-12-26 03:40:48 +00:00
|
|
|
|
{
|
2024-05-14 01:54:53 +00:00
|
|
|
|
LogLevelStart(levelId, EventLevelStartModeContinue, levelType, levelName, puzzleId, true, extra:extra);
|
2023-12-26 03:40:48 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2024-05-15 01:58:22 +00:00
|
|
|
|
/// 游戏点击 Replay 重玩关卡
|
2023-12-26 03:40:48 +00:00
|
|
|
|
/// </summary>
|
2024-04-02 07:27:34 +00:00
|
|
|
|
/// <param name="levelId"></param>
|
2024-05-13 09:20:45 +00:00
|
|
|
|
/// <param name="levelType"></param>
|
2023-12-26 03:40:48 +00:00
|
|
|
|
/// <param name="levelName"></param>
|
2024-05-14 01:54:53 +00:00
|
|
|
|
/// <param name="puzzleId"></param>
|
2024-05-13 09:20:45 +00:00
|
|
|
|
public static void LogLevelReplay(int levelId, string levelType = LevelTypeMain,
|
2024-05-14 01:54:53 +00:00
|
|
|
|
string levelName = "", string puzzleId = "", Dictionary<string, object> extra = null)
|
2023-12-26 03:40:48 +00:00
|
|
|
|
{
|
2024-05-14 01:54:53 +00:00
|
|
|
|
LogLevelStart(levelId, EventLevelStartModeReplay,levelType, levelName, puzzleId, true, extra:extra);
|
2023-12-26 03:40:48 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2024-05-15 01:58:22 +00:00
|
|
|
|
/// 关卡结束打点
|
2023-12-26 03:40:48 +00:00
|
|
|
|
/// </summary>
|
2024-05-15 01:58:22 +00:00
|
|
|
|
/// <param name="levelId">关卡Id</param>
|
|
|
|
|
|
/// <param name="result">success:成功;fail:失败;exit:退出;timeout:超时;replay:重玩...</param>
|
|
|
|
|
|
/// <param name="levelType">关卡类型: 主线:main</param>
|
|
|
|
|
|
/// <param name="levelName">关卡名称: main_01_9001, daily_challenge_81011</param>
|
|
|
|
|
|
/// <param name="puzzleId">配置/谜题/图片/自定义Id: 101120</param>
|
|
|
|
|
|
/// <param name="duration">关卡完成时长(单位:毫秒)</param>
|
|
|
|
|
|
/// <param name="step">步数(有则上报)</param>
|
|
|
|
|
|
/// <param name="score">分数(有则上报)</param>
|
|
|
|
|
|
/// <param name="extra">扩展数据</param>
|
2024-04-02 07:27:34 +00:00
|
|
|
|
public static void LogLevelEnd(int levelId, string result = EventLevelEndSuccess,
|
2024-05-14 01:54:53 +00:00
|
|
|
|
string levelType = LevelTypeMain, string levelName = "", string puzzleId = "",
|
2024-05-11 06:19:11 +00:00
|
|
|
|
int? duration = null, int? step = null, int? score = null, Dictionary<string, object> extra = null )
|
2023-12-26 03:40:48 +00:00
|
|
|
|
{
|
2024-01-08 03:31:58 +00:00
|
|
|
|
if (!IsInitialSuccess)
|
|
|
|
|
|
{
|
2024-05-07 12:37:57 +00:00
|
|
|
|
UnityEngine.Debug.LogError($"{Tag} :: LogLevelEnd {levelId} :: Please call <GuruSDK.Start()> first, before you call <LogLevelEnd>.");
|
2024-01-08 03:31:58 +00:00
|
|
|
|
return;
|
|
|
|
|
|
}
|
2024-05-13 09:20:45 +00:00
|
|
|
|
|
2023-12-26 03:40:48 +00:00
|
|
|
|
if (InitConfig.AutoRecordFinishedLevels)
|
|
|
|
|
|
{
|
2024-01-23 09:15:40 +00:00
|
|
|
|
if(result == EventLevelEndSuccess){
|
2024-05-13 09:20:45 +00:00
|
|
|
|
if(levelType == LevelTypeMain)
|
2024-04-02 07:27:34 +00:00
|
|
|
|
{
|
|
|
|
|
|
if (levelId > Model.SuccessLevelId) Model.SuccessLevelId = levelId; // 自动记录关卡完成次数
|
|
|
|
|
|
}
|
2024-01-23 09:15:40 +00:00
|
|
|
|
Model.TotalPlayedCount++; // 自动记录关卡总次数
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-12-26 03:40:48 +00:00
|
|
|
|
|
2024-04-02 07:27:34 +00:00
|
|
|
|
Analytics.BLevel = Model.SuccessLevelId; // 记录 BLevel
|
2023-12-26 03:40:48 +00:00
|
|
|
|
Analytics.BPlay = Model.TotalPlayedCount; // 记录 BPlay
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-05-14 01:54:53 +00:00
|
|
|
|
Analytics.LogLevelEnd(levelId, result, levelName, levelType, puzzleId, duration, step, score, extra);
|
2023-12-26 03:40:48 +00:00
|
|
|
|
}
|
2024-05-13 09:20:45 +00:00
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 关卡首次通关
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="levelType"></param>
|
|
|
|
|
|
/// <param name="levelName"></param>
|
|
|
|
|
|
/// <param name="level"></param>
|
|
|
|
|
|
/// <param name="result"></param>
|
|
|
|
|
|
/// <param name="duration"></param>
|
|
|
|
|
|
/// <param name="extra"></param>
|
|
|
|
|
|
public static void LevelFirstEnd(string levelType, string levelName, int level,
|
|
|
|
|
|
string result = EventLevelEndSuccess, int? duration = null, Dictionary<string, object> extra = null)
|
|
|
|
|
|
{
|
|
|
|
|
|
Analytics.LevelFirstEnd(levelType, levelName, level, result, duration, extra);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2023-12-26 03:40:48 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 游戏失败打点
|
|
|
|
|
|
/// 需要为游戏记录详细的失败原因
|
|
|
|
|
|
/// </summary>
|
2024-04-02 07:27:34 +00:00
|
|
|
|
public static void LogLevelFail(int levelId,
|
2024-05-14 01:54:53 +00:00
|
|
|
|
string levelType = LevelTypeMain, string levelName = "", string puzzleId = "",
|
2024-05-11 06:19:11 +00:00
|
|
|
|
int? duration = null, int? step = null, int? score = null , Dictionary<string, object> extra = null)
|
2023-12-26 03:40:48 +00:00
|
|
|
|
{
|
2024-05-14 01:54:53 +00:00
|
|
|
|
LogLevelEnd(levelId, EventLevelEndFail, levelType, levelName, puzzleId, duration, step, score, extra);
|
2023-12-26 03:40:48 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 因退出关卡导致游戏失败
|
|
|
|
|
|
/// </summary>
|
2024-04-02 07:27:34 +00:00
|
|
|
|
public static void LogLevelFailExit(int levelId,
|
2024-05-14 01:54:53 +00:00
|
|
|
|
string levelType = LevelTypeMain, string levelName = "", string puzzleId = "",
|
2024-05-11 06:19:11 +00:00
|
|
|
|
int? duration = null, int? step = null, int? score = null, Dictionary<string, object> extra = null)
|
2023-12-26 03:40:48 +00:00
|
|
|
|
{
|
2024-05-14 01:54:53 +00:00
|
|
|
|
LogLevelEnd(levelId, EventLevelEndExit, levelType, levelName, puzzleId, duration, step, score, extra);
|
2023-12-26 03:40:48 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 因关卡超时导致游戏失败
|
|
|
|
|
|
/// </summary>
|
2024-04-02 07:27:34 +00:00
|
|
|
|
public static void LogLevelFailTimeout(int levelId,
|
2024-05-14 01:54:53 +00:00
|
|
|
|
string levelType = LevelTypeMain, string levelName = "", string puzzleId = "",
|
2024-05-11 06:19:11 +00:00
|
|
|
|
int? duration = null, int? step = null, int? score = null, Dictionary<string, object> extra = null)
|
2023-12-26 03:40:48 +00:00
|
|
|
|
{
|
2024-05-14 01:54:53 +00:00
|
|
|
|
LogLevelEnd(levelId, EventLevelEndTimeout, levelType, levelName, puzzleId, duration, step, score, extra);
|
2023-12-26 03:40:48 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 玩家(角色)升级事件
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="playerLevel"></param>
|
|
|
|
|
|
/// <param name="playerName"></param>
|
2024-05-15 01:58:22 +00:00
|
|
|
|
/// <param name="extra">扩展数据</param>
|
2024-05-11 06:19:11 +00:00
|
|
|
|
public static void LogLevelUp(int playerLevel, string playerName, Dictionary<string, object> extra = null)
|
2023-12-26 03:40:48 +00:00
|
|
|
|
{
|
2024-01-08 03:31:58 +00:00
|
|
|
|
if (!IsInitialSuccess)
|
|
|
|
|
|
{
|
2024-05-07 12:37:57 +00:00
|
|
|
|
UnityEngine.Debug.LogError($"{Tag} :: LogLevelUp {playerLevel} :: Please call <GuruSDK.Start()> first, before you call <LogLevelUp>.");
|
2024-01-08 03:31:58 +00:00
|
|
|
|
return;
|
|
|
|
|
|
}
|
2024-05-11 06:19:11 +00:00
|
|
|
|
Analytics.LevelUp(playerLevel, playerName, extra);
|
2023-12-26 03:40:48 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 玩家解锁成就
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="achievementName"></param>
|
2024-05-15 01:58:22 +00:00
|
|
|
|
/// <param name="extra">扩展数据</param>
|
2024-05-11 06:19:11 +00:00
|
|
|
|
public static void LogAchievement(string achievementName, Dictionary<string, object> extra = null)
|
2023-12-26 03:40:48 +00:00
|
|
|
|
{
|
2024-01-08 03:31:58 +00:00
|
|
|
|
if (!IsInitialSuccess)
|
|
|
|
|
|
{
|
2024-05-07 12:37:57 +00:00
|
|
|
|
UnityEngine.Debug.LogError($"{Tag} :: LogAchievement {achievementName} :: Please call <GuruSDK.Start()> first, before you call <LogAchievement>.");
|
2024-01-08 03:31:58 +00:00
|
|
|
|
return;
|
|
|
|
|
|
}
|
2024-05-11 06:19:11 +00:00
|
|
|
|
Analytics.UnlockAchievement(achievementName, extra);
|
2023-12-26 03:40:48 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
#region 用户属性
|
|
|
|
|
|
|
2024-04-07 08:17:46 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 提前调用用户属性
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
private static void InitUserProperties()
|
|
|
|
|
|
{
|
|
|
|
|
|
if (!IsInitialSuccess)
|
|
|
|
|
|
{
|
2024-05-07 12:37:57 +00:00
|
|
|
|
UnityEngine.Debug.LogError($"{Tag} :: InitUserProperties :: Please call <GuruSDK.Start()> first, before you call <InitUserProperties>.");
|
2024-04-07 08:17:46 +00:00
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-05-17 12:21:45 +00:00
|
|
|
|
Debug.Log($"[SDK] --- PurchasedCount:{Model.PurchasedCount}");
|
|
|
|
|
|
Debug.Log($"[SDK] --- IsIapUser:{Model.IsIapUser}");
|
|
|
|
|
|
|
2024-05-17 02:28:35 +00:00
|
|
|
|
SetUserIsIAP(Model.IsIapUser); // 预先设置用户的 IAP User 属性
|
2024-04-07 08:17:46 +00:00
|
|
|
|
SetUserBLevel(Model.SuccessLevelId); // 预先设置用户的 BLevel 属性
|
|
|
|
|
|
SetUserBPlay(Model.TotalPlayedCount); // 预先设置用户的 BPlay 属性
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2023-12-26 03:40:48 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 设置用户属性
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="key"></param>
|
|
|
|
|
|
/// <param name="value"></param>
|
|
|
|
|
|
public static void SetUserProperty(string key, string value)
|
2024-01-08 03:31:58 +00:00
|
|
|
|
{
|
|
|
|
|
|
if (!IsInitialSuccess)
|
|
|
|
|
|
{
|
2024-05-07 12:37:57 +00:00
|
|
|
|
UnityEngine.Debug.LogError($"{Tag} :: SetUserProperty {key}:{value} ::Please call <GuruSDK.Start()> first, before you call <SetUserProperty>.");
|
2024-01-08 03:31:58 +00:00
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
Analytics.SetUserProperty(key, value);
|
|
|
|
|
|
}
|
2023-12-26 03:40:48 +00:00
|
|
|
|
|
|
|
|
|
|
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}");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-05-16 10:58:29 +00:00
|
|
|
|
// public static void SetUserTotalCoins(int totalCoins)
|
|
|
|
|
|
// {
|
|
|
|
|
|
// SetUserProperty(Analytics.PropertyCoin, $"{totalCoins}");
|
|
|
|
|
|
// }
|
2023-12-26 03:40:48 +00:00
|
|
|
|
|
2024-05-16 10:58:29 +00:00
|
|
|
|
public static void SetUserFreeCoins(int freeCoins)
|
2023-12-26 03:40:48 +00:00
|
|
|
|
{
|
2024-05-16 10:58:29 +00:00
|
|
|
|
SetUserProperty(Analytics.PropertyNonIAPCoin, $"{freeCoins}");
|
2023-12-26 03:40:48 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
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}");
|
|
|
|
|
|
}
|
2024-04-03 04:47:25 +00:00
|
|
|
|
|
|
|
|
|
|
public static void SetUserIsIAP(bool isIapUser)
|
|
|
|
|
|
{
|
|
|
|
|
|
SetUserProperty(Analytics.PropertyIsIAPUser, isIapUser? "true" : "false");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-03-06 04:36:41 +00:00
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
#region SDK 打点
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Log SDK boost time
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="time"></param>
|
|
|
|
|
|
private static void LogSDKInitTime(double time)
|
|
|
|
|
|
{
|
2024-04-09 10:54:37 +00:00
|
|
|
|
Analytics.Track(Consts.EventSDKInfo, new Dictionary<string, dynamic>()
|
2024-03-06 04:36:41 +00:00
|
|
|
|
{
|
2024-05-11 03:34:51 +00:00
|
|
|
|
{ "boost_time", time.ToString("F6") },
|
2024-03-15 04:59:20 +00:00
|
|
|
|
{ Consts.PropertyDeviceID, DeviceId },
|
2024-05-11 03:34:51 +00:00
|
|
|
|
{ "version", Version}
|
2024-03-15 04:59:20 +00:00
|
|
|
|
}, new Analytics.EventSetting()
|
|
|
|
|
|
{
|
|
|
|
|
|
EnableFirebaseAnalytics = true,
|
|
|
|
|
|
});
|
2024-04-17 13:56:46 +00:00
|
|
|
|
|
|
|
|
|
|
SetUserProperty("sdk_version", Version);
|
2024-03-15 04:59:20 +00:00
|
|
|
|
}
|
2024-05-11 02:28:58 +00:00
|
|
|
|
|
2024-04-10 06:08:49 +00:00
|
|
|
|
#endregion
|
|
|
|
|
|
|
2024-05-13 09:20:45 +00:00
|
|
|
|
#region IAP 打点
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 当付费页面打开时调用
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="scene">付费页面名称, 默认为 Store</param>
|
|
|
|
|
|
/// <param name="productId">列表中首个商品的 ProductId </param>
|
|
|
|
|
|
public static void OnIAPPageOpen(string scene = "Store", string productId = "")
|
|
|
|
|
|
{
|
|
|
|
|
|
if (string.IsNullOrEmpty(productId))
|
|
|
|
|
|
{
|
|
|
|
|
|
if (GuruSettings.Instance != null && (GuruSettings.Instance.Products?.Length ?? 0) > 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
productId = GuruSettings.Instance.Products[0].ProductId;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
Analytics.IAPImp(scene, productId);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 当付费页面关闭时调用
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="scene"></param>
|
|
|
|
|
|
/// <param name="productId"></param>
|
|
|
|
|
|
public static void OnIAPPageClose(string scene = "Store", string productId = "")
|
|
|
|
|
|
{
|
|
|
|
|
|
if (string.IsNullOrEmpty(productId))
|
|
|
|
|
|
{
|
|
|
|
|
|
productId = GuruIAP.Instance.CurrentBuyingProductId;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Analytics.IAPClose(scene, productId);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
2024-04-10 06:08:49 +00:00
|
|
|
|
#region 经济打点
|
|
|
|
|
|
|
|
|
|
|
|
// ************************************************************************************************
|
|
|
|
|
|
// *
|
|
|
|
|
|
// * 经济打点
|
|
|
|
|
|
// * 内容详参: https://docs.google.com/spreadsheets/d/1xYSsAjbrwqeJm7panoVzHO0PeGRQVDCR4e2CU9OPEzk/edit#gid=0
|
|
|
|
|
|
// *
|
|
|
|
|
|
// ************************************************************************************************
|
|
|
|
|
|
|
|
|
|
|
|
//---------------------------------------- EARN ----------------------------------------
|
|
|
|
|
|
/// <summary>
|
2024-05-15 01:58:22 +00:00
|
|
|
|
/// 基础收入接口. 可直接调用此接口上报相关参数
|
2024-04-10 06:08:49 +00:00
|
|
|
|
/// 获取虚拟货币/道具.
|
|
|
|
|
|
/// 基础接口, 不推荐项目组直接调用
|
|
|
|
|
|
/// 请直接调用其他对应场景的统计接口
|
|
|
|
|
|
/// </summary>
|
2024-05-15 01:58:22 +00:00
|
|
|
|
/// <param name="currencyName">货币名称</param>
|
|
|
|
|
|
/// <param name="value">货币增加值 10</param>
|
|
|
|
|
|
/// <param name="balance">结算后货币总量 20 -> 30</param>
|
|
|
|
|
|
/// <param name="category">消耗类型, 默认值请赋 reward</param>
|
|
|
|
|
|
/// <param name="levelName">当前关卡或者人物等级名称</param>
|
|
|
|
|
|
/// <param name="itemName">购买道具名称</param>
|
|
|
|
|
|
/// <param name="scene">购买场景如 Store, Workbench, Sign, Ads....</param>
|
2024-04-10 06:08:49 +00:00
|
|
|
|
public static void EarnVirtualCurrency(string currencyName,
|
|
|
|
|
|
int value, int balance,
|
|
|
|
|
|
string category = "", string itemName = "",
|
2024-05-11 06:19:11 +00:00
|
|
|
|
string levelName = "", string scene = "", Dictionary<string, object> extra = null)
|
2024-04-10 06:08:49 +00:00
|
|
|
|
{
|
2024-05-11 06:19:11 +00:00
|
|
|
|
Analytics.EarnVirtualCurrency(currencyName, value, balance, category, itemName,levelName, scene, extra);
|
2024-04-10 06:08:49 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <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,
|
2024-05-11 06:19:11 +00:00
|
|
|
|
string[] props = null, Dictionary<string, object> extra = null)
|
2024-04-10 06:08:49 +00:00
|
|
|
|
{
|
|
|
|
|
|
//---- Currency -----
|
|
|
|
|
|
if (value > 0)
|
|
|
|
|
|
{
|
2024-05-11 06:19:11 +00:00
|
|
|
|
EarnVirtualCurrency(currencyName, value, balance, category, itemName, levelName, scene, extra);
|
2024-04-10 06:08:49 +00:00
|
|
|
|
}
|
|
|
|
|
|
//---- Props --------
|
|
|
|
|
|
if (null != props)
|
|
|
|
|
|
{
|
|
|
|
|
|
int i = 0;
|
|
|
|
|
|
while (i < props.Length)
|
|
|
|
|
|
{
|
2024-05-11 06:19:11 +00:00
|
|
|
|
EarnVirtualCurrency(props[i], 1, 0, category, itemName, levelName, scene, extra);
|
2024-04-10 06:08:49 +00:00
|
|
|
|
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 = "",
|
2024-05-11 06:19:11 +00:00
|
|
|
|
string scene = "home", string[] props = null, Dictionary<string, object> extra = null)
|
2024-04-10 06:08:49 +00:00
|
|
|
|
{
|
|
|
|
|
|
string category = Consts.CurrencyCategoryReward;
|
|
|
|
|
|
string itemName = "sign";
|
2024-05-11 06:19:11 +00:00
|
|
|
|
|
|
|
|
|
|
EarnVirtualCurrencyAndProps(currencyName, value, balance, category, itemName, levelName, scene, props, extra);
|
2024-04-10 06:08:49 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// IAP 付费购买. 获得货币/道具
|
|
|
|
|
|
/// <li>通常类型: Coin 收入 </li>
|
|
|
|
|
|
/// <li>特殊类型: Coin + Props (道具列表) </li>
|
|
|
|
|
|
/// <li>特殊类型: Props (道具列表) </li>
|
|
|
|
|
|
/// </summary>
|
2024-04-10 08:01:00 +00:00
|
|
|
|
/// <param name="currencyName">IAP 道具名称</param>
|
|
|
|
|
|
/// <param name="productId">IAP 道具商品 ID </param>
|
2024-04-10 06:08:49 +00:00
|
|
|
|
/// <param name="value">赚取金额</param>
|
|
|
|
|
|
/// <param name="balance">货币总量(累加后)</param>
|
|
|
|
|
|
/// <param name="levelName">当前关卡名称</param>
|
|
|
|
|
|
/// <param name="scene">应用场景</param>
|
|
|
|
|
|
/// <param name="props">获取的道具名称列表</param>
|
2024-04-10 08:01:00 +00:00
|
|
|
|
public static void EarnVirtualCurrencyByIAP(string currencyName, string productId,
|
2024-04-10 06:08:49 +00:00
|
|
|
|
int value = 0, int balance = 0, string levelName = "",
|
2024-05-11 06:19:11 +00:00
|
|
|
|
string scene = "store", string[] props = null, Dictionary<string, object> extra = null)
|
2024-04-10 06:08:49 +00:00
|
|
|
|
{
|
|
|
|
|
|
string category = Consts.CurrencyCategoryIAP;
|
2024-04-10 08:01:00 +00:00
|
|
|
|
string itemName = productId;
|
2024-05-11 06:19:11 +00:00
|
|
|
|
EarnVirtualCurrencyAndProps(currencyName, value, balance, category, itemName, levelName, scene, props, extra);
|
2024-04-10 06:08:49 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <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 = "",
|
2024-05-11 06:19:11 +00:00
|
|
|
|
string scene = "store", string[] props = null, Dictionary<string, object> extra = null)
|
2024-04-10 06:08:49 +00:00
|
|
|
|
{
|
|
|
|
|
|
string category = Consts.CurrencyCategoryReward;
|
|
|
|
|
|
string itemName = "ads";
|
2024-05-11 06:19:11 +00:00
|
|
|
|
EarnVirtualCurrencyAndProps(currencyName, value, balance, category, itemName, levelName, scene, props, extra);
|
2024-04-10 06:08:49 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <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 = "",
|
2024-05-11 06:19:11 +00:00
|
|
|
|
string scene = Consts.ParameterDefaultScene, string[] props = null, Dictionary<string, object> extra = null)
|
2024-04-10 06:08:49 +00:00
|
|
|
|
{
|
|
|
|
|
|
string category = Consts.CurrencyCategoryBonus;
|
|
|
|
|
|
string itemName = "ads";
|
2024-05-11 06:19:11 +00:00
|
|
|
|
EarnVirtualCurrencyAndProps(currencyName, value, balance, category, itemName, levelName, scene, props, extra);
|
2024-04-10 06:08:49 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <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 = "",
|
2024-05-11 06:19:11 +00:00
|
|
|
|
string scene = "store", string[] props = null, Dictionary<string, object> extra = null)
|
2024-04-10 06:08:49 +00:00
|
|
|
|
{
|
|
|
|
|
|
string category = Consts.CurrencyCategoryReward;
|
|
|
|
|
|
string itemName = "level";
|
2024-05-11 06:19:11 +00:00
|
|
|
|
EarnVirtualCurrencyAndProps(currencyName, value, balance, category, itemName, levelName, scene, props, extra);
|
2024-04-10 06:08:49 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <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,
|
2024-05-11 06:19:11 +00:00
|
|
|
|
int value = 1, int balance = 0, string levelName = "", Dictionary<string, object> extra = null)
|
2024-04-10 06:08:49 +00:00
|
|
|
|
{
|
|
|
|
|
|
string category = Consts.CurrencyCategoryIGC;
|
|
|
|
|
|
string itemName = currencyName;
|
2024-05-11 06:19:11 +00:00
|
|
|
|
EarnVirtualCurrencyAndProps(currencyName, value, balance, category, itemName, levelName, scene, props, extra);
|
2024-04-10 06:08:49 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 通过道具交换/合成或得了其他道具
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="propName"></param>
|
2024-04-10 08:01:00 +00:00
|
|
|
|
/// <param name="otherName"></param>
|
2024-04-10 06:08:49 +00:00
|
|
|
|
/// <param name="scene"></param>
|
|
|
|
|
|
/// <param name="value"></param>
|
|
|
|
|
|
/// <param name="balance"></param>
|
|
|
|
|
|
/// <param name="levelName"></param>
|
2024-04-10 08:01:00 +00:00
|
|
|
|
public static void EarnPropByProp(string propName, string otherName,
|
2024-04-10 06:08:49 +00:00
|
|
|
|
string scene = Consts.ParameterDefaultScene,
|
2024-05-11 06:19:11 +00:00
|
|
|
|
int value = 1, int balance = 0, string levelName = "", Dictionary<string, object> extra = null)
|
2024-04-10 06:08:49 +00:00
|
|
|
|
{
|
|
|
|
|
|
string category = Consts.CurrencyCategoryIGB;
|
2024-05-11 06:19:11 +00:00
|
|
|
|
EarnVirtualCurrency(propName, value, balance, category, otherName, levelName, scene, extra);
|
2024-04-10 06:08:49 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <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 = "",
|
2024-05-11 06:19:11 +00:00
|
|
|
|
string scene = "store", string[] props = null, Dictionary<string, object> extra = null)
|
2024-04-10 06:08:49 +00:00
|
|
|
|
{
|
|
|
|
|
|
string category = Consts.CurrencyCategoryIGB;
|
|
|
|
|
|
string itemName = "lottery";
|
2024-05-11 06:19:11 +00:00
|
|
|
|
EarnVirtualCurrencyAndProps(currencyName, value, balance, category, itemName, levelName, scene, props, extra);
|
2024-04-10 06:08:49 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-05-15 01:58:22 +00:00
|
|
|
|
//---------------------------------------- SPEND ----------------------------------------
|
2024-04-10 06:08:49 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2024-05-15 01:58:22 +00:00
|
|
|
|
/// 基础花费虚拟货币/道具
|
2024-04-10 06:08:49 +00:00
|
|
|
|
/// 基础接口, 不推荐项目组直接调用
|
|
|
|
|
|
/// 请直接调用其他对应场景的统计接口
|
|
|
|
|
|
/// </summary>
|
2024-05-15 01:58:22 +00:00
|
|
|
|
/// <param name="currencyName">货币名称</param>
|
|
|
|
|
|
/// <param name="value">货币消耗值 10</param>
|
|
|
|
|
|
/// <param name="balance">结算后货币总量 30 -> 20</param>
|
|
|
|
|
|
/// <param name="category">消耗类型, 默认值请赋 reward</param>
|
|
|
|
|
|
/// <param name="levelName">当前关卡或者人物等级名称</param>
|
|
|
|
|
|
/// <param name="itemName">购买道具名称</param>
|
|
|
|
|
|
/// <param name="scene">购买场景如 Store, Workbench, Sign, Ads....</param>
|
|
|
|
|
|
public static void SpendVirtualCurrency(string currencyName, int value, int balance, string category = "", string itemName = "",
|
2024-05-11 06:19:11 +00:00
|
|
|
|
string levelName = "", string scene = "", Dictionary<string, object> extra = null)
|
2024-04-10 06:08:49 +00:00
|
|
|
|
{
|
2024-05-11 06:19:11 +00:00
|
|
|
|
Analytics.SpendVirtualCurrency(currencyName, value, balance, category, itemName, levelName, scene, extra);
|
2024-04-10 06:08:49 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <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,
|
2024-05-11 06:19:11 +00:00
|
|
|
|
string levelName = "", string scene = "", Dictionary<string, object> extra = null)
|
2024-04-10 06:08:49 +00:00
|
|
|
|
{
|
2024-05-11 06:19:11 +00:00
|
|
|
|
SpendVirtualCurrencyWithProps(currencyName, new string[] {prop}, value, balance, levelName, scene, extra);
|
2024-04-10 06:08:49 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <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,
|
2024-05-11 06:19:11 +00:00
|
|
|
|
string levelName = "", string scene = "", Dictionary<string, object> extra = null)
|
2024-04-10 06:08:49 +00:00
|
|
|
|
{
|
|
|
|
|
|
string category = Consts.CurrencyCategoryProp;
|
|
|
|
|
|
if (props != null && props.Length > 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
int i = 0;
|
|
|
|
|
|
while (i < props.Length)
|
|
|
|
|
|
{
|
2024-05-11 06:19:11 +00:00
|
|
|
|
SpendVirtualCurrency(currencyName, value, balance, category, props[i], levelName, scene, extra);
|
2024-04-10 06:08:49 +00:00
|
|
|
|
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,
|
2024-05-11 06:19:11 +00:00
|
|
|
|
string levelName = "", string scene = "", Dictionary<string, object> extra = null)
|
2024-04-10 06:08:49 +00:00
|
|
|
|
{
|
2024-05-11 06:19:11 +00:00
|
|
|
|
SpendVirtualCurrencyWithBundles(currencyName, new string[] {bundle}, value, balance, levelName, scene, extra);
|
2024-04-10 06:08:49 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <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,
|
2024-05-11 06:19:11 +00:00
|
|
|
|
string levelName = "", string scene = "", Dictionary<string, object> extra = null)
|
2024-04-10 06:08:49 +00:00
|
|
|
|
{
|
|
|
|
|
|
string category = Consts.CurrencyCategoryBundle;
|
|
|
|
|
|
if (bundles != null && bundles.Length > 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
int i = 0;
|
|
|
|
|
|
while (i < bundles.Length)
|
|
|
|
|
|
{
|
2024-05-11 06:19:11 +00:00
|
|
|
|
SpendVirtualCurrency(currencyName, value, balance, category, bundles[i], levelName, scene, extra);
|
2024-04-10 06:08:49 +00:00
|
|
|
|
i++;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2024-04-10 08:01:00 +00:00
|
|
|
|
|
|
|
|
|
|
/// <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,
|
2024-05-11 06:19:11 +00:00
|
|
|
|
string levelName = "", string scene = "", string extraCategory = "", Dictionary<string, object> extra = null)
|
2024-04-10 08:01:00 +00:00
|
|
|
|
{
|
|
|
|
|
|
string category = string.IsNullOrEmpty(extraCategory) ? Consts.CurrencyCategoryProp : extraCategory;
|
2024-05-11 06:19:11 +00:00
|
|
|
|
SpendVirtualCurrency(propName, value, balance, category, otherName, levelName, scene, extra);
|
2024-04-10 08:01:00 +00:00
|
|
|
|
}
|
2024-04-10 06:08:49 +00:00
|
|
|
|
|
|
|
|
|
|
|
2023-12-26 03:40:48 +00:00
|
|
|
|
#endregion
|
2024-03-20 07:40:22 +00:00
|
|
|
|
|
|
|
|
|
|
#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
|
2023-12-26 03:40:48 +00:00
|
|
|
|
}
|
|
|
|
|
|
}
|