void OnPurchaseSuccess(string id) { purchasing = false; InAppPurchasesSystem.OnPurchaseSuccess -= OnPurchaseSuccess; InAppPurchasesSystem.OnPurchaseFail -= OnPurchaseFail; InAppPurchasesSystem.OnPurchaseCancel -= OnPurchaseFail; InAppProduct product = InAppPurchasesSystem.Instance.GetProduct(id); if (product != null) { #if UNITY_ANDROID AnalyticsBinding.LogEventPaymentAction(product.currencyCode, InAppPurchasesSystem.locale, "-" + product.price, id, 1, "lives_refill", "consumable", "", LoadLevelButton.lastUnlockedLevel); #else float price; if (!float.TryParse(product.price, out price)) { price = 0.99f; } AnalyticsBinding.LogEventPaymentAction(product.currencyCode, InAppPurchasesSystem.locale, -price, id, 1, "lives_refill", "consumable", "", LoadLevelButton.lastUnlockedLevel); #endif } // PlayerPrefs.SetInt(LivesSystem.livesKey, LivesSystem.maxLives); // PlayerPrefs.Save(); UserManagerCloud.Instance.CurrentUser.NumsLiveLeft = LivesSystem.maxLives; UserCloud.Serialize(UserManagerCloud.FILE_NAME_LOCAL); LivesSystem.instance.Lives = LivesSystem.maxLives; fsm.SendEvent(sendEvent); }
public void SetLevelStartAnalyticTimeEvent(bool levelFinished = false) { //TODO: when facebook will be integrated we must log per user analytics stats here. string analyticsLevelKey = string.Format("AnalyticsPlayedLevelTime{0}", Match3BoardRenderer.levelIdx); int levelPlayedTime = PlayerPrefs.GetInt(analyticsLevelKey, -1); if (levelPlayedTime == -1) { // Set the current played time for this level that has been started for the first time. levelPlayedTime = (int)TimeDaysSinceBaseUtc(); PlayerPrefs.SetInt(analyticsLevelKey, levelPlayedTime); PlayerPrefs.Save(); Debug.Log("[Match3BoardGameLogic] SetLevelStartAnalyticTimeEvent set the first timestamp for level: " + Match3BoardRenderer.levelIdx); } else if (levelPlayedTime < -1) { // This level has been handled by the analytics timing event and we don't need to do it again. Debug.Log("[Match3BoardGameLogic] SetLevelStartAnalyticTimeEvent -> Analytics timing event already handled for this level: " + Match3BoardRenderer.levelIdx); return; } if (levelFinished) { // Make sure this event is sent only once per level in the entire game's lifetime. (or until it's deleted and re-installed :D ) if (levelPlayedTime >= 0) { // Determine the amount of time passed since this level was first played until now(when it was completed). int elapsedDaysUntilFinished = (int)TimeDaysSinceBaseUtc() - levelPlayedTime; if (elapsedDaysUntilFinished < 0) { elapsedDaysUntilFinished = 0; } // Mark this level as handled by the analytics event. PlayerPrefs.SetInt(analyticsLevelKey, -2); AnalyticsBinding.LogEventTimingAction(string.Format("{0}_{1}", GetLevelType(), Match3BoardRenderer.levelIdx), (float)elapsedDaysUntilFinished); PlayerPrefs.Save(); } } }
public void SendEndGameAnalytics() { int remainingPlayAmount = winConditions.CachedRemainingPlayAmount < 0 ? 0 : winConditions.CachedRemainingPlayAmount; if (levelWon) { AnalyticsBinding.LogEventGameAction(characterUsed, "success", remainingPlayAmount.ToString(), GetLevelType(), Match3BoardRenderer.levelIdx); AnalyticsBinding.LogEventGameAction(characterUsed, "star_rating", (winConditions as WinScore).StarsReached.ToString(), GetLevelType(), Match3BoardRenderer.levelIdx); SetLevelStartAnalyticTimeEvent(true); } else { AnalyticsBinding.LogEventGameAction(characterUsed, "fail", Mathf.FloorToInt((winConditions as WinScore).CalculateObjectiveProgress() * 100f).ToString(), GetLevelType(), Match3BoardRenderer.levelIdx); } }
public void StartGame() { Debug.Log("[Match3BoardGameLogic] StartGame called..."); AnalyticsBinding.LogEventGameAction(characterUsed, "game_start", null, GetLevelType(), Match3BoardRenderer.levelIdx); SetLevelStartAnalyticTimeEvent(); IsGameOver = false; // Resume the main board game logic. SetBoardEnabledState(true); if (OnStartGame != null) { OnStartGame(); } TryCheckStableBoard(); }
void OnPurchaseSuccess(string id) { purchasing = false; InAppPurchasesSystem.OnPurchaseSuccess -= OnPurchaseSuccess; InAppPurchasesSystem.OnPurchaseFail -= OnPurchaseFail; InAppPurchasesSystem.OnPurchaseCancel -= OnPurchaseFail; InAppProduct product = InAppPurchasesSystem.Instance.GetProduct(id); if (product != null) { BasicItem itemComponent = item.itemPrefab.GetComponent <BasicItem>(); string subtype = "small"; if (packIndex == 1) { subtype = "medium"; } else if (packIndex == 2) { subtype = "large"; } #if UNITY_ANDROID AnalyticsBinding.LogEventPaymentAction(product.currencyCode, InAppPurchasesSystem.locale, "-" + product.price, id, 1, itemComponent.ItemName, "consumable", endGame ? "postgame" : "ingame", Match3BoardRenderer.levelIdx); #else float price; if (!float.TryParse(product.price, out price)) { price = 0.99f + packIndex * 1f; } AnalyticsBinding.LogEventPaymentAction(product.currencyCode, InAppPurchasesSystem.locale, -price, id, 1, itemComponent.ItemName, "consumable", endGame ? "postgame" : "ingame", Match3BoardRenderer.levelIdx); #endif } item.AddItems(itemCount + freeItemCount); buyFSM.SendEvent("BuyFinished"); }
public override void OnEnter() { AnalyticsBinding.LogEventNavigationAction(buttonPressed.Value, fromLocation.Value, toLocation.Value, targetUrl.Value); Finish(); }
public override void OnEnter() { AnalyticsBinding.LogEventPageView(location.Value, pageUrl.Value, message.Value); Finish(); }