you can now undo a purchase after buying an item from the shop
This commit is contained in:
parent
efc7a3deaf
commit
64b25a2029
12 changed files with 359 additions and 56 deletions
|
|
@ -30,11 +30,15 @@ public class PlayerController : MonoBehaviour {
|
|||
|
||||
public int Money => _money;
|
||||
|
||||
public delegate void OnMoneyChanged();
|
||||
public OnMoneyChanged onMoneyChangedCallback;
|
||||
|
||||
// Start is called before the first frame update
|
||||
private void Start() {
|
||||
_money = startMoney;
|
||||
_inventory = Inventory.instance;
|
||||
moneyTextMeshProUGUI.text = _money + "µ";
|
||||
|
||||
onMoneyChangedCallback += UpdateMoneyUI;
|
||||
}
|
||||
|
||||
public void SetSelectedItem(UsableItem item) {
|
||||
|
|
@ -52,6 +56,10 @@ public class PlayerController : MonoBehaviour {
|
|||
|
||||
public void ChangeMoney(int amount) {
|
||||
_money += amount;
|
||||
onMoneyChangedCallback?.Invoke();
|
||||
}
|
||||
|
||||
private void UpdateMoneyUI() {
|
||||
moneyTextMeshProUGUI.text = _money + "µ";
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue