public void Purchase(StoreAbilityVisual storeItem, AbilityConfig config) { if (DataPersistanceManager.PlayerData.CurrentCurrency >= config.Price) { // Store in persistance the ability equiped after discounting the // ability price from the player currency DataPersistanceManager.PlayerData.CurrentCurrency -= config.Price; DataPersistanceManager.PlayerData.ActiveAbility = config.AbilityID; ManagerHandler.Get <DataPersistanceManager>().Save(); OnAbilityPurchased?.Invoke(config); _currencyLabel.text = DataPersistanceManager.PlayerData.CurrentCurrency.ToString("n0"); } }
public override IEnumerator Initialization() { int activeAbility = DataPersistanceManager.PlayerData.ActiveAbility; // Initialize the store // show the buyable abilities foreach (var storeAbility in _allAbilities.Abilities) { StoreAbilityVisual visual = Instantiate(_storeItemPrefab, _itemsHolder, false); visual.Initialize(this, storeAbility, storeAbility.AbilityID == activeAbility); } _currencyLabel.text = DataPersistanceManager.PlayerData.CurrentCurrency.ToString("n0"); yield return(null); }