Beispiel #1
0
    void OnClick()
    {
        Gamestate_Gameplay gs = GameObject.FindGameObjectWithTag("Gamestate").GetComponent <Gamestate_Gameplay> ();

        if (gs)
        {
            gs.ShowNotImplemented();
        }
    }
    public void OnClickShopContent()
    {
        UIButton button = UIButton.current;

        if (button == null)
        {
            return;
        }

        Gamestate_Gameplay gs = GameObject.Find("Gamestate").GetComponent <Gamestate_Gameplay>();

        if (gs == null)
        {
            return;
        }

        ShopContent content = button.transform.parent.gameObject.GetComponent <ShopContent> ();

        if (content.type == ShopContentType.IAP)
        {
            if (content.uniqueID == "freecoins")
            {
                GUI_Dialog.InsertStack(gemuFreeCoins.gameObject);
                //if ( GameDataManager.GetTimerToWatchAds() > GameDataManager.TIMER_TO_WATCH_ADS )
                //{
                //if (GameDataManager.PlayUnityVideoAd ()) {
                //	StartCoroutine(ShowingAds());
                //} else {
                //	gs.ShowDialogBox ("Info", "Please wait...", false, "", this.gameObject);
                //}
                //}
                //else
                //	gs.ShowDialogBox("Info","Please wait to watch the next ads.",false,"",this.gameObject);
            }
            else if (PlayerPrefs.HasKey("joystick." + content.uniqueID) == true)
            {
                PlayerPrefs.SetString("playerjoy", content.uniqueID);
                gs.SetJoystick(content.uniqueID);
                RefreshJoystickStatus();
            }
            else if (PlayerPrefs.HasKey("claw." + content.uniqueID) == true)
            {
                PlayerPrefs.SetString("playerclaw", content.uniqueID);
                gs.SetClaw(content.uniqueID);
                RefreshClawStatus();
            }
            else
            {
                currentShopContent = content;
                AndroidInAppPurchaseManager.instance.purchase(currentShopContent.uniqueID);
                //OnSuccessfulPurchase(currentShopContent.uniqueID);
            }
        }
        else if (content.type == ShopContentType.PowerUp)
        {
            int gemucoins = GameManager.GEMUCOINS;
            if (gemucoins - content.Price >= 0)
            {
                currentShopContent = content;
                gs.ShowDialogBox(content.Name, content.Desc + "\n\nDo you want to buy ?", true, "buypowerup", this.gameObject);
                //gs.achievementManager.OnAchievementEvent(AchievementType.PowerPlay,1);
            }
            else
            {
                gs.ShowDialogBox("Info", "Not enough coins", false, "confirm", this.gameObject);
            }
        }
        else if (content.type == ShopContentType.Claw)
        {
            if (PlayerPrefs.HasKey("claw." + content.uniqueID) == false)
            {
                int gemucoins = GameManager.GEMUCOINS;
                if (gemucoins - content.Price >= 0)
                {
                    //currentShopContent = content;
                    //gs.ShowDialogBox(content.Name,content.Desc+"Do you want to buy ?",true,"buyclaw",this.gameObject);
                    PlayerPrefs.SetString("playerclaw", content.uniqueID);
                    gs.SetClaw(content.uniqueID);
                    RefreshClawStatus();
                }
                else
                {
                    //gs.ShowDialogBox("Info","Not enough GemuGold",false,"confirm",this.gameObject);
                }
            }
            else
            {
                PlayerPrefs.SetString("playerclaw", content.uniqueID);
                gs.SetClaw(content.uniqueID);
                RefreshClawStatus();
            }
        }
        else if (content.type == ShopContentType.Joystick)
        {
            if (PlayerPrefs.HasKey("joystick." + content.uniqueID) == false)
            {
                int gemucoins = GameManager.GEMUCOINS;
                if (gemucoins - content.Price >= 0)
                {
                    //currentShopContent = content;
                    //gs.ShowDialogBox(content.Name,content.Desc+"Do you want to buy ?",true,"buyjoystick",this.gameObject);
                    PlayerPrefs.SetString("playerjoy", content.uniqueID);
                    gs.SetJoystick(content.uniqueID);
                    RefreshJoystickStatus();
                }
                else
                {
                    //gs.ShowDialogBox("Info","Not enough GemuGold",false,"confirm",this.gameObject);
                }
            }
            else
            {
                PlayerPrefs.SetString("playerjoy", content.uniqueID);
                gs.SetJoystick(content.uniqueID);
                RefreshJoystickStatus();
            }
        }
        else if (content.type == ShopContentType.FreeCoin)
        {
            int gemucoins = GameManager.GEMUCOINS;
            if (gemucoins - content.Price >= 0)
            {
                currentShopContent = content;
                gs.ShowDialogBox(content.Name, "Do you want to buy ?", true, "buyenergy", this.gameObject);
            }
            else
            {
                gs.ShowDialogBox("Info", "Not enough GemuGold", false, "confirm", this.gameObject);
            }
        }
        else
        {
            gs.ShowNotImplemented();
        }

        PlayerPrefs.Save();
    }