using System; using asap.core; using game; using UniRx; public class TikTokEventManager : IDisposable { private static TikTokEventManager _instance; private CompositeDisposable disposable; private TikTokEventManager() { } public static void Init() { if(_instance != null) { _instance.Dispose(); _instance = null; } _instance = new TikTokEventManager(); _instance.disposable = new CompositeDisposable(); _instance.Subscribe(); UnityEngine.Debug.Log($"[TikTokEventManager]Init"); } public void Dispose() { disposable?.Dispose(); disposable = null; createTime = null; } private void Subscribe() { GContext.OnEvent().Subscribe(OnLvChange).AddTo(disposable); GContext.OnEvent().Where(_ => _.joinClub).Subscribe(OnJoinClub).AddTo(disposable); } private void OnLvChange(OnLvChangeEvent evt) { if(!IsFirstDay()) return; //UnityEngine.Debug.Log($"[TikTokEventManager]OnLvChange: {evt.lvl}"); switch(evt.lvl) { case 10: using(GEvent.GameEvent("af_d0_charalevel_10", true)){} break; case 20: using(GEvent.GameEvent("af_d0_charalevel_20", true)){} using(GEvent.GameEvent("af_d0_completetutorial", true)){} break; case 30: using(GEvent.GameEvent("af_d0_charalevel_30", true)){} break; case 40: using(GEvent.GameEvent("af_d0_charalevel_40", true)){} break; case 50: using(GEvent.GameEvent("af_d0_charalevel_50", true)){} break; case 60: using(GEvent.GameEvent("af_d0_charalevel_60", true)){} break; } } private void OnJoinClub(ClubStateChangeEvent evt) { using(GEvent.GameEvent("af_joinclub", true)){} } private static DateTime? createTime; public static bool IsFirstDay() { if(createTime == null) createTime = GContext.container.Resolve().CreateTime; var utcNow = ZZTimeHelper.UtcNow(); return (utcNow - createTime) < TimeSpan.FromHours(24); } }