private void Awake() { _soundManager = FindObjectOfType <SoundManager>(); _gamplayHud = FindObjectOfType <GamplayHUD>(); _scoreTracking = FindObjectOfType <ScoreTracking>(); _timeScaleZero = FindObjectOfType <TimeScaleZero>(); }
void Start() { InitializeSaveData(); _gamplayHud = FindObjectOfType <GamplayHUD>(); _gamplayHud.UpdateHighScoreUI(highScore); _gamplayHud.UpdateCoinText(coinsPickedUp); StartCoroutine(AddToScoreEverySecond()); }
//When the confirm purchase button is clicked void OnBuyButtonClick(ShopItem shopItem, GameObject item) { shopItem.isOwned = true; //Show purchased item GameObject ownedItem = Instantiate(ownedItemPrefab, itemsOwnedContainer); ownedItem.transform.GetChild(0).GetComponent <Image>().sprite = shopItem.itemSprite; //The button can no longer be interacted with, making UI reflect this item.GetComponent <Button>().interactable = false; item.transform.GetChild(0).GetComponent <Image>().color = Color.gray; item.transform.GetChild(1).GetComponent <Image>().color = Color.gray; item.transform.GetChild(2).GetComponent <Text>().text = "Owned"; //Subtract coins and update coin text PlayerPrefs.SetInt("coinsPickedUp", PlayerPrefs.GetInt("coinsPickedUp") - shopItem.itemPrice); _gamplayHud = FindObjectOfType <GamplayHUD>(); _gamplayHud.UpdateCoinText(PlayerPrefs.GetInt("coinsPickedUp")); Debug.Log("Purchased " + shopItem.name); }