Beispiel #1
0
    // Update the prices when an item is bought with virtual currency in the store
    public void OnGoodBalanceChanged(VirtualGood vg, int balance, int amountAdded)
    {
        GameObject temp_1 = GameObject.Find("store_ui_gr");
        if (temp_1 != null) { store_manager_script = temp_1.GetComponent<SOAPStoreManager>(); }

        string avatar_id = vg.ItemId;

        // To prevent erroring out when an item is bought with real money 
        // (store manager will attempt to look up "soap_soap_" without this check and fail)
        if (avatar_id.Contains("soap_"))
        {
            avatar_id = avatar_id.Replace("soap_", "");
        }

        // Update avatar and tail prices in the store
        if (avatar_id.Contains("avatar"))
        {
            store_manager_script.updatePrices(avatar_id);
        }
        else if (avatar_id.Contains("tail"))
        {
            store_manager_script.updatePrices(avatar_id);
        }

        // Unlock achievement for buying an avatar or tail with virtual currency
        #if UNITY_ANDROID
            unlockStoreAchievements(avatar_id)
        #endif
    }
Beispiel #2
0
    public void Update()
    {
        t = Time.deltaTime * 15f;
        if (t > 1f)
        {
            t = 1f;
        }
        if (Mathf.Abs(scrollRect.velocity.x) > 800f && !done)
        {
            touchUp();
        }
        if (!done && Mathf.Abs(scrollRect.velocity.x) < 800f)
        {
            rect.localPosition = Vector2.Lerp(rect.localPosition, targetPos, t);
            if (Vector3.Distance(rect.localPosition, targetPos) < 0.001f)
            {
                rect.localPosition = targetPos;
                done = true;
            }
        }

        Vector2 tempPos = new Vector2(Mathf.Round(rect.localPosition.x / (grid.cellSize.x + grid.spacing.x)) * (grid.cellSize.x + grid.spacing.x) * -1f, 0);

        for (int i = 0; i < transform.childCount; i++)
        {
            Transform child = transform.GetChild(i);

            if (child.localPosition.x == tempPos.x)
            {
                // Scale the middle avatar
                child.localScale = Vector3.Lerp(child.localScale, new Vector3(1.4f, 1.4f, 1f), t);

                avatar_name = child.name;

                // Update the button prices and the avatar name and type texts
                if (previous_avatar_name != avatar_name)
                {
                    previous_avatar_name = avatar_name;

                    // Set the avatar name and type in the store
                    string[] avatar_name_list = getAvatarNameAndType(avatar_name);
                    avatar_name_txt.text = avatar_name_list[0];
                    avatar_type_txt.text = avatar_name_list[1];

                    // Only updates prices if the avatar and tail are purchasable
                    store_manager_script.updatePrices(avatar_name);
                    store_manager_script.setAvatarID(avatar_name);

                    // Swap the avatars
                    avatar_swap_script.setAvatar(avatar_name);
                }
            }
            else
            {
                child.localScale = Vector3.Lerp(child.localScale, new Vector3(1f, 1f, 1f), t);
            }
        }
    }
Beispiel #3
0
    // Update the prices when an item is bought with real money in the store
    public void onItemPurchased(PurchasableVirtualItem pvi, string payload)
    {
        GameObject temp_1 = GameObject.Find("store_ui_gr");

        if (temp_1 != null)
        {
            store_manager_script = temp_1.GetComponent <SOAPStoreManager>();
        }

        string avatar_id = pvi.ItemId;

        // To prevent erroring out when an item is bought with real money
        // (store manager will attempt to look up "soap_soap_" without this check and fail)
        if (avatar_id.Contains("soap_"))
        {
            avatar_id = avatar_id.Replace("soap_", "");
        }

        // Unlock achievement for buying an avatar or tail with real money
        if (avatar_id.Contains("avatar"))
        {
            store_manager_script.updatePrices(avatar_id);
            #if UNITY_ANDROID
            Achievements.massiveFacialReconstructionAchievement();
            #endif
        }
        else if (avatar_id.Contains("tail"))
        {
            store_manager_script.updatePrices(avatar_id);
            #if UNITY_ANDROID
            Achievements.sheddingSeasonAchievement();
            #endif
        }

        // Give rocketman avatar and tail for removing ads
        if (avatar_id == "soap_no_ads")
        {
            RewardedAvatars.incrementAvatarBalance(RewardedAvatars.rocketman_avatar_rwd);
            RewardedAvatars.incrementAvatarBalance(RewardedAvatars.rocketman_tail_rwd);
        }
    }