public void BuyLives() { int coin = PlayerPrefs.GetInt("TotalCoin", 0); if (coin >= 100) { FindObjectOfType <FadeTrigger>().Fade(); if (ammoCount == 0) { AmmoMenu.gameObject.SetActive(true); ShopMenu.gameObject.SetActive(false); } else { LevelMenu.gameObject.SetActive(true); ShopMenu.gameObject.SetActive(false); } coin -= 100; PlayerPrefs.SetInt("TotalCoin", coin); PlayerPrefs.SetString("Lives", "OOOOO"); PlayerPrefs.SetInt("Health", 100); money.text = "<color=#3A6C41>M</color> " + PlayerPrefs.GetInt("TotalCoin", 0); lives.text = PlayerPrefs.GetString("Lives", "OOOOO"); } else { TextMeshProUGUI warningClone = Instantiate(noMoreCoin); UIMethods.PositionUI(warningClone.GetComponent <RectTransform>(), noMoreCoin.GetComponent <RectTransform>(), ShopMenu); warningClone.gameObject.SetActive(true); Destroy(warningClone.gameObject, 2.5f); } }
public void BuyAmmo() { int coin = PlayerPrefs.GetInt("TotalCoin", 0); if (coin >= 30) { FindObjectOfType <FadeTrigger>().Fade(); LevelMenu.gameObject.SetActive(true); AmmoMenu.gameObject.SetActive(false); coin -= 30; PlayerPrefs.SetInt("TotalCoin", coin); PlayerPrefs.SetInt("TotalAmmo", 30); money.text = "<color=#3A6C41>M</color> " + PlayerPrefs.GetInt("TotalCoin", 0); } else { TextMeshProUGUI warningClone = Instantiate(noMoreCoin); UIMethods.PositionUI(warningClone.GetComponent <RectTransform>(), noMoreCoin.GetComponent <RectTransform>(), AmmoMenu); warningClone.gameObject.SetActive(true); Destroy(warningClone.gameObject, 2.5f); } }