[Fix] Code visual
This commit is contained in:
@@ -3,46 +3,45 @@ using UnityEngine;
|
||||
|
||||
namespace YachtDice.Economy
|
||||
{
|
||||
|
||||
public sealed class CurrencyBank : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private int startingBalance = 500;
|
||||
|
||||
private int balance;
|
||||
|
||||
public int Balance => balance;
|
||||
|
||||
public event Action<int> OnBalanceChanged;
|
||||
|
||||
private void Awake()
|
||||
public class CurrencyBank : MonoBehaviour
|
||||
{
|
||||
balance = startingBalance;
|
||||
}
|
||||
[SerializeField] private int startingBalance = 500;
|
||||
|
||||
public void Add(int amount)
|
||||
{
|
||||
if (amount <= 0) return;
|
||||
private int balance;
|
||||
|
||||
balance += amount;
|
||||
OnBalanceChanged?.Invoke(balance);
|
||||
}
|
||||
public int Balance => balance;
|
||||
|
||||
public bool Spend(int amount)
|
||||
{
|
||||
if (amount <= 0) return false;
|
||||
if (balance < amount) return false;
|
||||
public event Action<int> OnBalanceChanged;
|
||||
|
||||
balance -= amount;
|
||||
OnBalanceChanged?.Invoke(balance);
|
||||
return true;
|
||||
}
|
||||
private void Awake()
|
||||
{
|
||||
balance = startingBalance;
|
||||
}
|
||||
|
||||
public bool CanAfford(int amount) => balance >= amount;
|
||||
public void Add(int amount)
|
||||
{
|
||||
if (amount <= 0) return;
|
||||
|
||||
public void SetBalance(int value)
|
||||
{
|
||||
balance = Mathf.Max(0, value);
|
||||
OnBalanceChanged?.Invoke(balance);
|
||||
balance += amount;
|
||||
OnBalanceChanged?.Invoke(balance);
|
||||
}
|
||||
|
||||
public bool Spend(int amount)
|
||||
{
|
||||
if (amount <= 0) return false;
|
||||
if (balance < amount) return false;
|
||||
|
||||
balance -= amount;
|
||||
OnBalanceChanged?.Invoke(balance);
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool CanAfford(int amount) => balance >= amount;
|
||||
|
||||
public void SetBalance(int value)
|
||||
{
|
||||
balance = Mathf.Max(0, value);
|
||||
OnBalanceChanged?.Invoke(balance);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user