Ejemplo n.º 1
0
    public void OnClick()
    {
        characterName = scrollColliderHandlerScript.GetCharacterName();

        if (buttonText.text != "Selected" && buttonText.text != "Select" && buttonText.text != "$0.99" && buttonText.text != "Watch 5 videos" && buttonText.text != "Share 5 times")
        {
            print(buttonText.text);
            print(buttonText.text.Split(' ')[0]);

            int.TryParse(buttonText.text.Split(' ')[0], out characterPrice);
            print(characterPrice);

            if (characterPrice <= currencyManagerScript.GetTotal())
            {
                print("Confirm Purchase: " + characterName + " for " + characterPrice.ToString() + " coins");
                question.text = "Confirm purchase for " + buttonText.text + "?";

                purchasePanel.SetActive(true);
            }
            else
            {
                insufficientFundsPanel.SetActive(true);
            }
        }
        else if (buttonText.text == "Select")
        {
            print(characterName);
            unlockScript.SelectCharacter(characterName);
            buttonText.text = "Selected";
        }
        else if (buttonText.text == "$0.99")
        {
            print("Buy Character");

            // Add other products here
            if (characterName == "Fancy Rainbow")
            {
                IAPManager.GetComponent <SimplePurchasing>().BuyProduct("RAINBOW_ID");
            }
        }
        else if (buttonText.text == "Watch 5 videos")
        {
            print("VID");
            //shopRewardedVideo.ShowVideo();
        }
        else if (buttonText.text == "Share 5 times")
        {
            print("SHARE");
            screenShotManager.ShareScreenshotWithText();
            shareAmount++;
            SecurePlayerPrefs.SetInt(progressBarShare.playerPrefsName, shareAmount);
            StartCoroutine(UpdateProgressBar());

            if (shareAmount >= 5)
            {
                unlockScript.UnlockCharacter(progressBarShare.characterName);
                buttonText.text = "Select";
                progressBarShare.gameObject.SetActive(false);
                SecurePlayerPrefs.SetInt("ProgressBar" + progressBarShare.characterName, 1);
            }
        }
        else
        {
            print("Character Already Selected");
        }
    }