Exemplo n.º 1
0
    public void OnPurchase()
    {
//		int golds = (int)EncryptionHandler64.Decrypt (PlayerPrefs.GetString("Golds"));
//		int totalscore = (int)EncryptionHandler64.Decrypt (PlayerPrefs.GetString("TotalScore"));

        if (MenuManager.totalscore >= coinsToUpgradeLevel[upgradeValue] && MenuManager.golds >= goldToUpgradeLevel[upgradeValue])
        {
            MenuManager.golds      -= goldToUpgradeLevel[upgradeValue];
            MenuManager.totalscore -= coinsToUpgradeLevel[upgradeValue];
            upgradeNoImages[upgradeValue + 1].SetActive(true);
            PlayerPrefs.SetString("TotalScore", EncryptionHandler64.Encrypt(MenuManager.totalscore.ToString()));
            PlayerPrefs.SetString("Golds", EncryptionHandler64.Encrypt(MenuManager.golds.ToString()));
            upgradeValue++;
            PlayerPrefs.SetString(myName + "Upgrade", EncryptionHandler64.Encrypt(upgradeValue.ToString()));

            if (myName == "Grills")
            {
                //StartCoroutine(FacebookHandler._instance.SendSingleKey("GrilUpLevel",upgradeValue.ToString())) ;
                FacebookHandler._instance.send_single_key("GrilUpLevel", upgradeValue.ToString());
            }
            if (myName == "USCoke")
            {
                //StartCoroutine(FacebookHandler._instance.SendSingleKey("ColaTraysLevel",upgradeValue.ToString())) ;
                FacebookHandler._instance.send_single_key("ColaTraysLevel", upgradeValue.ToString());
            }
            if (myName == "Plate")
            {
                //StartCoroutine(FacebookHandler._instance.SendSingleKey("HotTraysLevel",upgradeValue.ToString())) ;
                FacebookHandler._instance.send_single_key("HotTraysLevel", upgradeValue.ToString());
            }
            if (myName == "ChinaBowls")
            {
                //StartCoroutine(FacebookHandler._instance.SendSingleKey("SoupBowlLevel",upgradeValue.ToString())) ;
                FacebookHandler._instance.send_single_key("SoupBowlLevel", upgradeValue.ToString());
            }
            if (myName == "ChinaPans")
            {
                //StartCoroutine(FacebookHandler._instance.SendSingleKey("SkilletLevel",upgradeValue.ToString())) ;
                FacebookHandler._instance.send_single_key("SkilletLevel", upgradeValue.ToString());
            }
            if (myName == "ChinaSoupContainer")
            {
                //StartCoroutine(FacebookHandler._instance.SendSingleKey("StockPotLevel",upgradeValue.ToString())) ;
                FacebookHandler._instance.send_single_key("StockPotLevel", upgradeValue.ToString());
            }
            if (myName == "ChinaPlate")
            {
                //StartCoroutine(FacebookHandler._instance.SendSingleKey("NoodleDishesLevel",upgradeValue.ToString())) ;
                FacebookHandler._instance.send_single_key("NoodleDishesLevel", upgradeValue.ToString());
            }
            if (myName == "ItalyCoke")
            {
                //StartCoroutine(FacebookHandler._instance.SendSingleKey("ColaTraysItalyLevel",upgradeValue.ToString())) ;
                FacebookHandler._instance.send_single_key("ColaTraysItalyLevel", upgradeValue.ToString());
            }
            if (myName == "ItalyPlate")
            {
                //StartCoroutine(FacebookHandler._instance.SendSingleKey("DishesLevel",upgradeValue.ToString())) ;
                FacebookHandler._instance.send_single_key("DishesLevel", upgradeValue.ToString());
            }
            if (myName == "Oven")
            {
                //StartCoroutine(FacebookHandler._instance.SendSingleKey("OvenLevel",upgradeValue.ToString())) ;
                FacebookHandler._instance.send_single_key("OvenLevel", upgradeValue.ToString());
            }

            if (myName == "AusPlate")
            {
                //StartCoroutine(FacebookHandler._instance.SendSingleKey("DishesAusLevel",upgradeValue.ToString())) ;
                FacebookHandler._instance.send_single_key("DishesAusLevel", upgradeValue.ToString());
            }

            if (myName == "AusCoke")
            {
                //StartCoroutine(FacebookHandler._instance.SendSingleKey("ColaTraysAusLevel",upgradeValue.ToString())) ;
                FacebookHandler._instance.send_single_key("ColaTraysAusLevel", upgradeValue.ToString());
            }

            if (myName == "Fries")
            {
                //StartCoroutine(FacebookHandler._instance.SendSingleKey("DeepFrierLevel",upgradeValue.ToString())) ;
                FacebookHandler._instance.send_single_key("DeepFrierLevel", upgradeValue.ToString());
            }

            if (myName == "AusGrills")
            {
                //StartCoroutine(FacebookHandler._instance.SendSingleKey("GrillUpAusLevel",upgradeValue.ToString())) ;
                FacebookHandler._instance.send_single_key("GrillUpAusLevel", upgradeValue.ToString());
            }


//			equipmentPanel.totalGoldText.text = golds.ToString ();
//			equipmentPanel.totalCoinsText.text = totalscore.ToString ();
            equipmentPanel.CallDecrementCoin();
            OnClickToShow();
            if (equ_number == 10)
            {
                PlayerPrefs.SetInt("Fridge", 1);

                //StartCoroutine(FacebookHandler._instance.SendSingleKey("FridgeLevel","1")) ;
                FacebookHandler._instance.send_single_key("FridgeLevel", "1");
                equipmentPanel.purchaseButton.SetActive(false);
            }
        }
        else
        {
            if ((MenuManager.totalscore < coinsToUpgradeLevel[upgradeValue]))
            {
                MenuManager._instance.lastPanel     = equipmentPanel.gameObject;
                MenuManager._instance.lastPanelName = "EquipmentUpdrade";
                MenuManager._instance.Insufficinetcoin();
            }
            else if ((MenuManager.golds < goldToUpgradeLevel[upgradeValue]))
            {
                MenuManager._instance.Insufficinetgold();
                MenuManager._instance.lastPanel     = equipmentPanel.gameObject;
                MenuManager._instance.lastPanelName = "EquipmentUpdrade";
            }
            //Debug.Log("insufficient funds");
        }
//		PlayerPrefs.GetInt ("Golds");
//		PlayerPrefs.SetInt ("TotalScore",PlayerPrefs.GetInt ("TotalScore"));
    }