Updated to use CurrencyAmmount
This commit is contained in:
@@ -46,7 +46,7 @@ namespace Fruitomation.Game
|
|||||||
default:
|
default:
|
||||||
throw new ArgumentOutOfRangeException();
|
throw new ArgumentOutOfRangeException();
|
||||||
}
|
}
|
||||||
|
|
||||||
return builder.ToString();
|
return builder.ToString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,6 +21,9 @@ namespace Fruitomation.Game.Items
|
|||||||
[SerializeField, InspectorReadOnly("Item Type")]
|
[SerializeField, InspectorReadOnly("Item Type")]
|
||||||
private ItemType InternalItemType = ItemType.None;
|
private ItemType InternalItemType = ItemType.None;
|
||||||
|
|
||||||
|
[SerializeField, InspectorReadOnly("Item Value")]
|
||||||
|
private CurrencyAmount InternalItemValue;
|
||||||
|
|
||||||
public ItemType CurrentType
|
public ItemType CurrentType
|
||||||
{
|
{
|
||||||
get => InternalItemType;
|
get => InternalItemType;
|
||||||
@@ -138,8 +141,7 @@ namespace Fruitomation.Game.Items
|
|||||||
if (harvest)
|
if (harvest)
|
||||||
{
|
{
|
||||||
ItemInfo info = ItemInfoRegistry.Get(CurrentType);
|
ItemInfo info = ItemInfoRegistry.Get(CurrentType);
|
||||||
float money = Random.Range(info.MinMoney, info.MaxMoney);
|
MoneyController.Add(InternalItemValue);
|
||||||
MoneyController.Add(money);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Destroy(gameObject);
|
Destroy(gameObject);
|
||||||
|
|||||||
@@ -71,8 +71,7 @@ namespace Fruitomation.Game.Items
|
|||||||
[SerializeField] private CustomBehaviourType CustomBehaviour;
|
[SerializeField] private CustomBehaviourType CustomBehaviour;
|
||||||
|
|
||||||
public GameObject Prefab;
|
public GameObject Prefab;
|
||||||
public float MinMoney;
|
public float BaseItemValue;
|
||||||
public float MaxMoney;
|
|
||||||
|
|
||||||
public CustomItemBehaviour GetCustomBehaviour()
|
public CustomItemBehaviour GetCustomBehaviour()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using PashaBibko.Pacore.Attributes;
|
using PashaBibko.Pacore.Attributes;
|
||||||
|
using Fruitomation.Game;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
namespace Fruitomation.Global
|
namespace Fruitomation.Global
|
||||||
@@ -7,16 +8,14 @@ namespace Fruitomation.Global
|
|||||||
{
|
{
|
||||||
private static MoneyController Instance;
|
private static MoneyController Instance;
|
||||||
|
|
||||||
[SerializeField, InspectorReadOnly("Game State")] private double InternalCurrentMoney;
|
[SerializeField, InspectorReadOnly("Current Money")]
|
||||||
|
private CurrencyAmount InternalCurrentMoney = new();
|
||||||
|
public static CurrencyAmount Current => Instance.InternalCurrentMoney;
|
||||||
|
|
||||||
public static double Current
|
public static void Add(CurrencyAmount amount)
|
||||||
{
|
{
|
||||||
get => Instance.InternalCurrentMoney;
|
|
||||||
set => Instance.InternalCurrentMoney = value;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void Add(double amount) => Instance.InternalCurrentMoney += amount;
|
|
||||||
|
|
||||||
private void Awake()
|
private void Awake()
|
||||||
{
|
{
|
||||||
if (Instance is not null)
|
if (Instance is not null)
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ namespace Fruitomation.UI
|
|||||||
|
|
||||||
private void Update()
|
private void Update()
|
||||||
{
|
{
|
||||||
MoneyText.text = $"Current Money: ${MoneyController.Current:F1}";
|
MoneyText.text = $"Current Money: {MoneyController.Current.AsString()}";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user