Example #1
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 UNITY_ANDROID
            unlockStoreAchievements(avatar_id)
        #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);
        }
    }
Example #2
0
    // Update the players score in the game screen, unlock score related acivements and store avatars
    public void update_score()
    {
        current_score++;
        string string_score = current_score.ToString();

        #if UNITY_ANDROID
        // Unlock achievements for reaching specific scores
        switch (string_score)
        {
        case "5":
            Achievements.unlockAchivement(GPGSIds.achievement_beginner);
            break;

        case "10":
            Achievements.unlockAchivement(GPGSIds.achievement_intermediate);
            break;

        case "15":
            Achievements.unlockAchivement(GPGSIds.achievement_proficient);
            break;

        case "20":
            Achievements.unlockAchivement(GPGSIds.achievement_master);
            break;

        case "30":
            Achievements.unlockAchivement(GPGSIds.achievement_expert);
            break;

        case "40":
            Achievements.unlockAchivement(GPGSIds.achievement_orochimarus_disciple);
            break;
        }
        #endif

        // Unlock score related avatars
        switch (string_score)
        {
        case "8":
            RewardedAvatars.incrementAvatarBalance(RewardedAvatars.alien_avatar_rwd);
            RewardedAvatars.incrementAvatarBalance(RewardedAvatars.alien_tail_rwd);
            break;

        case "20":
            RewardedAvatars.incrementAvatarBalance(RewardedAvatars.cyborg_avatar_rwd);
            RewardedAvatars.incrementAvatarBalance(RewardedAvatars.cyborg_tail_rwd);
            break;
        }


        // Update the game screen score text
        game_screen_score.text = current_score.ToString();

        int best_score = getScore();
        if (current_score > best_score)
        {
            setScore(current_score);
        }
    }
Example #3
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));
            }
        }
    }
Example #4
0
    // Give reward avatars when successfully posting to facebook or twitter
    public void onSocialActionFinished(Provider provider, SocialActionType action, string payload)
    {
        // provider is the social provider
        // action is the social action (like, post status, etc..) that finished
        // payload is an identification string that you can give when you initiate the social action operation and want to receive back upon its completion

        string social_provider = payload;

        Debug.Log(provider);

        if (social_provider == "facebook")
        {
            RewardedAvatars.incrementAvatarBalance(RewardedAvatars.ghost_avatar_rwd);
            RewardedAvatars.incrementAvatarBalance(RewardedAvatars.ghost_tail_rwd);
        }
        else if (social_provider == "twitter")
        {
            RewardedAvatars.incrementAvatarBalance(RewardedAvatars.star_avatar_rwd);
            RewardedAvatars.incrementAvatarBalance(RewardedAvatars.star_tail_rwd);
        }
    }
Example #5
0
    // Update the store button prices
    public void updatePrices(string item_id)
    {
        // Default avatars and tails
        if (item_id == "default_avatar" || item_id == "default_tail" || item_id == "orange_avatar" || item_id == "orange_tail")
        {
            coin_buy_button.gameObject.SetActive(false);
            money_buy_button.gameObject.SetActive(false);
            avatar_purchase_info.SetActive(true);
            reward_description_go.SetActive(false);
        }

        // Check balance of reward avatar
        else if (RewardedAvatars.avatar_balance_index_map.ContainsKey(item_id))
        {
            coin_buy_button.gameObject.SetActive(false);
            money_buy_button.gameObject.SetActive(false);

            if (RewardedAvatars.isAvatarUnlocked(item_id))
            {
                avatar_purchase_info.SetActive(true);
                reward_description_go.SetActive(false);
            }
            else
            {
                avatar_purchase_info.SetActive(false);
                reward_description_go.SetActive(true);
                reward_description_go.GetComponent <Text>().text = RewardedAvatars.avatar_earn_text_map[item_id];
            }
        }

        // For all other avatars update the prices
        else
        {
            string[] price_list = getPrices(item_id);
            coin_buy_button.GetComponentInChildren <Text>().text  = price_list[0];
            money_buy_button.GetComponentInChildren <Text>().text = "$" + price_list[1];

            bool can_afford = StoreInventory.CanAfford(item_id);

            // If user cannot afford disable the coin buy button
            if (can_afford)
            {
                coin_buy_button.enabled = true;
            }
            else
            {
                coin_buy_button.enabled = false;
            }

            // If user already bought don't show the buy buttons
            if (StoreInventory.GetItemBalance(item_id) == 1 || StoreInventory.GetItemBalance("soap_" + item_id) == 1)
            {
                coin_buy_button.gameObject.SetActive(false);
                money_buy_button.gameObject.SetActive(false);
                reward_description_go.SetActive(false);
                avatar_purchase_info.SetActive(true);
            }
            else
            {
                coin_buy_button.gameObject.SetActive(true);
                money_buy_button.gameObject.SetActive(true);
                reward_description_go.SetActive(false);
                avatar_purchase_info.SetActive(false);
            }
        }
    }