public void DroppingCoinOnDeath() { PlayerStats playerStats = FindObjectOfType <PlayerStats>(); CurrencyCounter currencyCounter = FindObjectOfType <CurrencyCounter>(); if (playerStats != null) { playerStats.AddCoins(enemyStats.coinsDrop); if (currencyCounter != null) { currencyCounter.SetCoinText(playerStats.coinCount); } } }
// Start is called before the first frame update void Start() { CheckSaveFile(); //CheckSavedProfile(); if (PlayerPrefs.HasKey("_coins")) { PlayerStats playerStats = FindObjectOfType <PlayerStats>(); CurrencyCounter currencyCounter = FindObjectOfType <CurrencyCounter>(); if (playerStats != null) { playerStats.coinCount = PlayerPrefs.GetInt("_coins"); if (currencyCounter != null) { currencyCounter.SetCoinText(playerStats.coinCount); } } } }