public void BuyCotsumeNew() { if (idToCheck != null) //check lai gui qua nhieu goi tin { foreach (Cotsume item in cotsume) { if (item.id == idToCheck) { if (item.levelUnlock < 50) { if (coins.coins >= item.cost) { //Debug.Log("You can buy"); coins.Buy(item.cost); item.checkBuy = true; if (item.checkBuy == true) { BuyCotsume.SetActive(false); UpgradeCotsume.SetActive(true); if (item.checkUse == true) { Equip.gameObject.SetActive(false); UnEquip.gameObject.SetActive(true); } else if (item.checkUse == false) { Equip.gameObject.SetActive(true); UnEquip.gameObject.SetActive(false); } } foreach (ButtonSkinUI button in buttonSkinUI) { if (button.idCotsume == idToCheck) { button.GetComponent <Image>().sprite = spriteBuyCotsume; } } SaveSkin(); } else { Debug.Log("You don't have enough money"); } } } } } }
public void buy() { if (dataButtonBuy) { string id = dataButtonBuy.id; int local = 0; Debug.Log(id); for (int i = 0; i < weapon.Length; i++) { if (weapon[i].id == id) { local = i; } } Debug.Log(local); if (level.levelplayer >= weapon[local].levelUnlock) // check level { if (coins.coins >= weapon[local].cost) { coins.Buy(weapon[local].cost); weapon[local].checkBuy = true; foreach (ButtonStoreUI item in ButtonStoreUI) { if (item.id == id) { Debug.Log(item.id); item.checkBuy = true; item.SetValues(); } } SaveWeapon(); } else { Debug.Log("You don't have enough money"); } } if (weapon[local].levelUnlock > 50 && weapon[local].checkVideoUnlock) { CheckVideoRewardWeapon2(); } } }
public void BuyPow() { if (idCheck != null) { foreach (Power item in power) { if (item.id == idCheck) { //if (item.amount < item.maxAmount) //{ Debug.Log(item.id); Buy.enabled = true; costPow.text = item.cost.ToString(); if (coins.coins >= item.cost) { //Debug.Log("you can buy"); coins.Buy(item.cost); item.amount++; numberPow.text = item.amount.ToString(); SaveData(); } else { Debug.Log("You don't have enough money"); } // if (item.amount > item.maxAmount) //{ // item.amount = item.maxAmount; // } // } } } } }