using PashaBibko.Pacore.Attributes; using UnityEngine; namespace Fruitomation.Global { [CreateInstanceOnStart] public class MoneyController : MonoBehaviour { private static MoneyController Instance; [SerializeField, InspectorReadOnly("Current Money")] private double InternalCurrentMoney; public static double CurrentAmount => Instance.InternalCurrentMoney; public static void ResetCurrentMoney() { Instance.InternalCurrentMoney = 0f; PlayerInfo.Data.CurrentMoney = 0f; } public static void Add(double amount) { Instance.InternalCurrentMoney += amount; } public static bool CouldBuy(double amount) { double val = Instance.InternalCurrentMoney - amount; return val > 0f; } public static bool CanBuy(double amount) { double val = Instance.InternalCurrentMoney - amount; if (val > 0f) { Instance.InternalCurrentMoney = val; return true; } return false; } private void Awake() { if (Instance is not null) { Debug.LogError("Cannot have multiple instances of [MoneyController]"); return; } Instance = this; } private void Start() { InternalCurrentMoney = PlayerInfo.Data.CurrentMoney; } } }