diff --git a/Runtime/Wallet/CurrencyAccount.cs b/Runtime/Wallet/CurrencyAccount.cs index 5eb9303..d2a86de 100644 --- a/Runtime/Wallet/CurrencyAccount.cs +++ b/Runtime/Wallet/CurrencyAccount.cs @@ -1,5 +1,4 @@ using System; -using System.Security.Cryptography; namespace CurrencySystem { @@ -10,16 +9,26 @@ public sealed class CurrencyAccount : ICurrency private float _multiplier = 1; private IVault _vault; + /// + /// Передает общее кол-во денег на счету + /// [field: NonSerialized] - public event ICurrency.CurrencyEvent OnCurrencyChange; + + public event ICurrency.CurrencyEvent OnNewAmount; + /// + /// Передает сумму, на которую счет изменился + /// + [field: NonSerialized] + public event ICurrency.CurrencyEvent OnChange; private double Amount { get { return _vault.Amount; } set { + OnChange?.Invoke(value - _vault.Amount); _vault.Amount = value; - NotifyEvent(); + OnNewAmount?.Invoke(value); } } @@ -35,12 +44,6 @@ public CurrencyAccount(string currencyCode, double amount, float multiplier = 1) _vault = new Vault(amount, currencyCode); } - private void NotifyEvent() - { - Aes.Create(); - OnCurrencyChange?.Invoke(Amount); - } - public void Add(double amount) { Amount += amount * _multiplier; diff --git a/Runtime/Wallet/ICurrency.cs b/Runtime/Wallet/ICurrency.cs index ea51a6a..e168c03 100644 --- a/Runtime/Wallet/ICurrency.cs +++ b/Runtime/Wallet/ICurrency.cs @@ -2,8 +2,9 @@ namespace CurrencySystem { public interface ICurrency { - delegate void CurrencyEvent(double newAmount); - event CurrencyEvent OnCurrencyChange; + delegate void CurrencyEvent(double amount); + event CurrencyEvent OnNewAmount; + event CurrencyEvent OnChange; public string CurrencyCode { get; } public double Get(); public void Add(double amount);