コード例 #1
0
    private void OnItemPurchased(PurchasableVirtualItem pvi, string paylod)
    {
        Debug.Log(string.Format("GNOME: ItemPurchased - ItemId: {0}", pvi.ItemId));

        // Set the item information
        ItemHitBuilder itemHitBuilder = new ItemHitBuilder().SetTransactionID(pvi.ID).SetName(pvi.Name).SetSKU(pvi.ItemId);

        // Then set the price
        PurchaseWithMarket      marketItem  = pvi.PurchaseType as PurchaseWithMarket;
        PurchaseWithVirtualItem virtualItem = pvi.PurchaseType as PurchaseWithVirtualItem;

        if (marketItem != null)
        {
            itemHitBuilder.SetPrice(marketItem.MarketItem.Price).SetCurrencyCode(marketItem.MarketItem.MarketCurrencyCode);
        }

        if (virtualItem != null)
        {
            itemHitBuilder.SetPrice(virtualItem.Amount).SetCurrencyCode("Tokens");
        }

        // Now log it
        GoogleAnalyticsV3.instance.LogItem(itemHitBuilder);

        Debug.Log(string.Format("GNOME: Analytics: {0}, {1}, {2}", "Purchase", this.PurchaseButtonLocation, pvi.ItemId));
    }
コード例 #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="PurchasableVirtualItem"/> class.
        /// </summary>
        /// <param name="jsonObject">The json object.</param>
        public PurchasableVirtualItem(JObject jsonObject) : base(jsonObject)
        {
            JObject purchasableObj = jsonObject.Value <JObject>(StoreJSONConsts.PURCHASABLE_ITEM);
            String  purchaseType   = purchasableObj.Value <String>(StoreJSONConsts.PURCHASE_TYPE);

            if (purchaseType == StoreJSONConsts.PURCHASE_TYPE_MARKET)
            {
                JObject marketItemObj =
                    purchasableObj.Value <JObject>(StoreJSONConsts.PURCHASE_MARKET_ITEM);

                mPurchaseType = new PurchaseWithMarket(new MarketItem(marketItemObj));
            }
            else if (purchaseType == StoreJSONConsts.PURCHASE_TYPE_VI)
            {
                String itemId = purchasableObj.Value <String>(StoreJSONConsts.PURCHASE_VI_ITEMID);
                int    amount = purchasableObj.Value <int>(StoreJSONConsts.PURCHASE_VI_AMOUNT);

                mPurchaseType = new PurchaseWithVirtualItem(itemId, amount);
            }
            else
            {
                SoomlaUtils.LogError(TAG, "IabPurchase type not recognized !");
            }

            if (mPurchaseType != null)
            {
                mPurchaseType.setAssociatedItem(this);
            }
        }
コード例 #3
0
    public void SetSpecialStageItem(
        SpecialStageLifetimeVg specialStage, LevelSelectCreator levelSelect, SpecialStageSelectButton selectStageButton)
    {
        this.specialStageVG           = specialStage;
        this.levelSelectCreator       = levelSelect;
        this.specialStageSelectButton = selectStageButton;

        PurchaseWithVirtualItem purchaseType = (PurchaseWithVirtualItem)specialStage.PurchaseType;

        this.Message.text = string.Format("Would you like to purchase this stage for {0} tokens?", purchaseType.Amount);
    }
コード例 #4
0
        //each VirtualGood gets created seperately
        VirtualGood CreateGood(IAPObject obj, bool market)
        {
            PurchaseType purchaseType = null;
            if (market)
                purchaseType = new PurchaseWithMarket(obj.GetIdentifier(), 0.00);
            else
                purchaseType = new PurchaseWithVirtualItem(obj.virtualPrice.name, obj.virtualPrice.amount);

            switch (obj.type)
            {
                case IAPType.SingleUseVG:
                    return new SingleUseVG(obj.title, obj.description, obj.id, purchaseType);
                case IAPType.SingleUsePackVG:
                    return new SingleUsePackVG(obj.specific, obj.amount, obj.title, obj.description, obj.id, purchaseType);
                case IAPType.LifetimeVG:
                    return new LifetimeVG(obj.title, obj.description, obj.id, purchaseType);
                case IAPType.EquippableVG:
                    EquippableVG.EquippingModel equipModel = EquippableVG.EquippingModel.LOCAL;
                    if (obj.specific == EquippableVG.EquippingModel.CATEGORY.ToString()) equipModel = EquippableVG.EquippingModel.CATEGORY;
                    else if (obj.specific == EquippableVG.EquippingModel.GLOBAL.ToString()) equipModel = EquippableVG.EquippingModel.GLOBAL;
                    return new EquippableVG(equipModel, obj.title, obj.description, obj.id, purchaseType);
                case IAPType.UpgradeVG:
                    string[] props = obj.specific.Split(';');
                    return new UpgradeVG(props[0], string.IsNullOrEmpty(props[2]) ? null : props[2], string.IsNullOrEmpty(props[1]) ? null : props[1],
                                         obj.title, obj.description, obj.id, purchaseType);
                default: return null;
            }
        }
コード例 #5
0
        //each CurrencyPack gets created seperately
        VirtualCurrencyPack CreateCurrencyPack(IAPObject obj, bool market)
        {
            PurchaseType purchaseType = null;
            if(market)
                purchaseType = new PurchaseWithMarket(obj.GetIdentifier(), 0.00);
            else
                purchaseType = new PurchaseWithVirtualItem(obj.virtualPrice.name, obj.virtualPrice.amount);

            return new VirtualCurrencyPack(obj.title, obj.description, obj.id, obj.amount,
                                           obj.specific, purchaseType);
        }