示例#1
0
    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);
    }
    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");
    }