Files
Liubing\LB 3d8d4d18f3 first commit
先修复一下,错误的场景

删除不必要的钓场资产

修复into场景

update:更新meta文件,修复报错

update:修复资源

修复第一章节建造

修复建造第三章

update:删除多余内容

update:更新README.md

update:还原图标

update:更新README

update:更新配置
2026-04-28 02:17:22 +08:00

168 lines
4.0 KiB
C#

using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using asap.core;
using Newtonsoft.Json.Linq;
using UnityEngine;
public class GEvent : IDisposable
{
private JObject content = new JObject();
private static JObject globalContent = new JObject();
private string eventName;
private bool afSend = false;
private bool gaSend = true;
private const string TA_APPID_KEY = "ta_appid";
private const string TA_URL_KEY = "ta_url";
private static bool _hasInit = false;
public static void Init()
{
globalContent.RemoveAll();
}
public static void SetProp(string key, object prop)
{
var props = new Dictionary<string, object>(){{key, prop}};
SetProps(props);
}
public static void SetProps(Dictionary<string, object> props)
{
ThinkingData.Analytics.TDAnalytics.SetSuperProperties(props);
}
public static void SetUserProp(string key, object prop, bool once = false)
{
var props = new Dictionary<string, object>(){{key, prop}};
SetUserProps(props, once);
}
public static void SetUserProps(Dictionary<string, object> props, bool once = false)
{
if(once)
{
ThinkingData.Analytics.TDAnalytics.UserSetOnce(props);
}
else
{
ThinkingData.Analytics.TDAnalytics.UserSet(props);
}
}
public static void SetGlobalContent(string key, string value)
{
if(globalContent.ContainsKey(key)) return;
globalContent.Add(key, value);
}
public static void OnLogin(string userID, string customUserID)
{
ThinkingData.Analytics.TDAnalytics.Login(customUserID);
}
private GEvent(string eventName, bool afSend = false, bool gaSend = true)
{
this.eventName = eventName;
this.afSend = afSend;
this.gaSend = gaSend;
}
public GEvent AddContent(string key, string value)
{
content[key] = value;
return this;
}
public GEvent AddContent(string key, int value)
{
content[key] = value;
return this;
}
public GEvent AddContent(string key, bool value)
{
content[key] = value;
return this;
}
public GEvent AddContent(string key, float value)
{
content[key] = value;
return this;
}
public GEvent AddContent(string key, JToken value)
{
content[key] = value;
return this;
}
public GEvent WithGAEvent(string eventName)
{
this.eventName = eventName;
this.afSend = true;
this.gaSend = true;
return this;
}
public void Dispose()
{
foreach (var kv in globalContent)
{
if(!content.ContainsKey(kv.Key))
content.Add(kv.Key, kv.Value);
}
Dictionary<string, object> properties = content.ToObject<Dictionary<string, object>>();
ThinkingData.Analytics.TDAnalytics.Track(eventName, properties);
content.RemoveAll();
content = null;
}
public static GEvent TackEvent(string eventName, bool afSend = false, bool gaSend = true)
{
return new GEvent(eventName, afSend, gaSend);
}
public static GEvent GameEvent(string eventName, bool afSend = false, bool gaSend = true)
{
return new GEvent(eventName, afSend, gaSend);
}
public static GEvent SpendCreditEvent(bool afSend = false, bool gaSend = true)
{
return new GEvent("spend_credit", afSend, gaSend);
}
public static GEvent CompleteRegistrationEvent()
{
return new GEvent("complete_registration", true, true);
}
public static GEvent RegistrationEvent()
{
return new GEvent("registration_method", true, true);
}
public static GEvent LoginEvent()
{
return new GEvent("login", true, true);
}
public static GEvent RevenueEvent(bool enableS2S)
{
return new GEvent("purchase", !enableS2S, gaSend: true);
}
public static void ADRevenueEvent(string adUnitId, object adInfo)
{
}
}