Esempio n. 1
0
//	public void OnGoodBalanceChanged(VirtualGood good, int balance, int amountAdded)
//	{
//		Debug.Log ("Balance changed");
//		int id = GetID(good.ItemId);
//		if(id > 0 && balance > 0)
//			FrogPackages.Instance.RestorePurchase(id);
    //else if(id > 0 && balance < 1)
    //	FrogPackages.Instance.LockPackage(id);
//	}

    public void onMarketPurchase(PurchasableVirtualItem pvi, string payload, Dictionary <string, string> extra)
    {
        int id = GetID(pvi.ItemId);

        if (id > 0 && pvi.GetBalance() > 0)
        {
            frogPackages.PurchaseFrogFromStore(id);
        }
    }
Esempio n. 2
0
    // Set the avatar and tail player pref to the name of the selected (middle) avatar game object in the store scroll
    public void setAvatar(string avatar_name)
    {
        int virtual_item_balance = 0;
        int market_item_balance  = 0;

        // Default avatar and tail balance is always 1
        if (avatar_name == "default_avatar" || avatar_name == "default_tail" || avatar_name == "orange_avatar" || avatar_name == "orange_tail")
        {
            virtual_item_balance = 1;
        }

        // Check balance of reward avatar
        else if (RewardedAvatars.avatar_balance_index_map.ContainsKey(avatar_name))
        {
            if (RewardedAvatars.isAvatarUnlocked(avatar_name))
            {
                virtual_item_balance = 1;
            }
        }

        // Look for balances on avatars and tails that are purchasable
        else
        {
            PurchasableVirtualItem virtual_item = (PurchasableVirtualItem)StoreInfo.GetItemByItemId(avatar_name);
            PurchasableVirtualItem market_item  = (PurchasableVirtualItem)StoreInfo.GetItemByItemId("soap_" + avatar_name);
            virtual_item_balance = virtual_item.GetBalance();
            market_item_balance  = market_item.GetBalance();
        }

        // Set the player pref if the item has been earned/purchased
        if (virtual_item_balance == 1 || market_item_balance == 1)
        {
            if (avatar_name.Contains("avatar"))
            {
                PlayerPrefs.SetString("Avatar", avatar_name);
                Debug.Log(string.Format("Avatar player pref set to: {0}", avatar_name));
            }

            else
            {
                PlayerPrefs.SetString("Tail", avatar_name);
                Debug.Log(string.Format("Tail player pref set to: {0}", avatar_name));
            }
        }
    }