Added cash counter
This commit is contained in:
31
Assets/Scripts/MoneyController.cs
Normal file
31
Assets/Scripts/MoneyController.cs
Normal file
@@ -0,0 +1,31 @@
|
||||
using PashaBibko.Pacore.Attributes;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Fruitomation
|
||||
{
|
||||
[CreateInstanceOnStart] public class MoneyController : MonoBehaviour
|
||||
{
|
||||
private static MoneyController Instance;
|
||||
|
||||
[SerializeField, InspectorReadOnly("Game State")] private ulong InternalCurrentMoney;
|
||||
|
||||
public static ulong Current
|
||||
{
|
||||
get => Instance.InternalCurrentMoney;
|
||||
set => Instance.InternalCurrentMoney = value;
|
||||
}
|
||||
|
||||
public static void Add(ulong amount) => Instance.InternalCurrentMoney += amount;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
if (Instance is not null)
|
||||
{
|
||||
Debug.LogError("Cannot have multiple instances of [MoneyController]");
|
||||
return;
|
||||
}
|
||||
|
||||
Instance = this;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user