private static int SetEvent(eventId id, bool autoSave = true) { if (eventDic != null && eventDic.ContainsKey(id)) { eventDic[id]++; int count = eventDic[id]; if (autoSave) { PlayerPrefs.SetInt(id.ToString(), count); PlayerPrefs.Save(); } return(count); } return(0); }
public static void Log(eventId id) { if (instance == null && eventDic == null) { return; } try { int count = SetEvent(id); if (id == eventId.level_up || id == eventId.session) { #if USE_APPSFLYER AppsFlyer.sendEvent(id.ToString(), new Dictionary <string, string> { { id.ToString(), count.ToString() } }); #endif Debug.Log(TAG + "Log " + id.ToString() + " " + count); return; } if (id == eventId.level_up || id == eventId.ad_banner_show || id == eventId.ad_banner_click || id == eventId.ad_interstitial_show || id == eventId.ad_interstitial_click || id == eventId.ad_videorewared_show || id == eventId.ad_videorewared_click) { #if USE_APPSFLYER AppsFlyer.sendEvent(id.ToString(), new Dictionary <string, string> { { id.ToString(), count.ToString() } }); #endif Debug.Log(TAG + "Log " + id.ToString() + " " + count); } string counter = count.ToString(); if (count > 10) { counter = "N"; } string eventName = id + "_" + counter; if ((id == eventId.ad_interstitial_show || id == eventId.ad_interstitial_click) && count >= 5 && count % 5 != 0) { Debug.Log(TAG + "Log " + eventName + " RETURN " + count); return; } else if ((id == eventId.ad_videorewared_show || id == eventId.ad_videorewared_click) && count >= 5 && count % 5 != 0) { Debug.Log(TAG + "Log " + eventName + " RETURN " + count); return; } else if ((id == eventId.ad_banner_show || id == eventId.ad_banner_click) && count >= 10 && count % 10 != 0) { Debug.Log(TAG + "Log " + eventName + " RETURN " + count); return; } #if USE_APPSFLYER AppsFlyer.sendEvent(eventName.ToLower(), new Dictionary <string, string> { { id.ToString(), count.ToString() } }); #endif Debug.Log(TAG + "Log " + eventName + " " + count); } catch (Exception ex) { Debug.LogError(TAG + "Log " + ex.Message); } }