Files
Shopping_UnityVR/Assets/02_Scripts/Data/Player/PlayerWallet.cs
2026-05-11 13:00:44 +09:00

37 lines
858 B
C#

using System;
using UnityEngine;
using UnityEngine.Serialization;
namespace VRShopping.Player
{
public class PlayerWallet : MonoBehaviour
{
// 예산 (Inspector에서 초기값 설정)
[SerializeField, Min(0), FormerlySerializedAs("Budget")]
private int _budget;
// UI 갱신용 이벤트
public event Action<int> OnBudgetChanged;
public int Budget => _budget;
private void Start()
{
OnBudgetChanged?.Invoke(_budget);
}
public bool PayMoney(int cost)
{
//예산이 비용보다 많을시
if (_budget >= cost)
{
_budget -= cost;
OnBudgetChanged?.Invoke(_budget);
return true;
}
//예산 부족
return false;
}
}
}