private void Awake()
 {
     _soundManager  = FindObjectOfType <SoundManager>();
     _gamplayHud    = FindObjectOfType <GamplayHUD>();
     _scoreTracking = FindObjectOfType <ScoreTracking>();
     _timeScaleZero = FindObjectOfType <TimeScaleZero>();
 }
示例#2
0
    void Start()
    {
        InitializeSaveData();

        _gamplayHud = FindObjectOfType <GamplayHUD>();
        _gamplayHud.UpdateHighScoreUI(highScore);
        _gamplayHud.UpdateCoinText(coinsPickedUp);

        StartCoroutine(AddToScoreEverySecond());
    }
示例#3
0
    //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);
    }