public void Load() { CurrencyDto dto = SaveManager.Get(SaveKeys.CurrencyDataKey, new CurrencyDto()) as CurrencyDto; if (dto == null) { return; } // set totalCoins to the save game value _totalCoins = dto.TotalCoins; OnCoinAmountChanged?.Invoke(_totalCoins, CurrencyType.Regular); }
/// <summary> /// Player spent coins. /// </summary> /// <param name="amount">Amount of coins spent</param> /// <param name="type">Type of currency spent</param> public void SpendCoins(int amount, CurrencyType type) { _totalCoins -= amount; OnCoinAmountChanged?.Invoke(_totalCoins, type); }