Removed currency ammount
This commit is contained in:
@@ -1,53 +0,0 @@
|
|||||||
using UnityEngine;
|
|
||||||
using System.Text;
|
|
||||||
using System;
|
|
||||||
|
|
||||||
namespace Fruitomation.Game
|
|
||||||
{
|
|
||||||
public enum CurrencyMagnitude
|
|
||||||
{
|
|
||||||
Ones,
|
|
||||||
Thousands,
|
|
||||||
Millions,
|
|
||||||
Billions,
|
|
||||||
Trillions
|
|
||||||
}
|
|
||||||
|
|
||||||
[Serializable] public class CurrencyAmount
|
|
||||||
{
|
|
||||||
[SerializeField] private CurrencyMagnitude Magnitude;
|
|
||||||
[SerializeField] private float Ammount;
|
|
||||||
|
|
||||||
public string AsString()
|
|
||||||
{
|
|
||||||
StringBuilder builder = new();
|
|
||||||
builder.Append(
|
|
||||||
Ammount > 10f
|
|
||||||
? $"${Ammount:I}"
|
|
||||||
: $"${Ammount:F1}"
|
|
||||||
);
|
|
||||||
|
|
||||||
switch (Magnitude)
|
|
||||||
{
|
|
||||||
case CurrencyMagnitude.Ones:
|
|
||||||
break;
|
|
||||||
case CurrencyMagnitude.Thousands:
|
|
||||||
builder.Append("K");
|
|
||||||
break;
|
|
||||||
case CurrencyMagnitude.Millions:
|
|
||||||
builder.Append("M");
|
|
||||||
break;
|
|
||||||
case CurrencyMagnitude.Billions:
|
|
||||||
builder.Append("B");
|
|
||||||
break;
|
|
||||||
case CurrencyMagnitude.Trillions:
|
|
||||||
builder.Append("T");
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
throw new ArgumentOutOfRangeException();
|
|
||||||
}
|
|
||||||
|
|
||||||
return builder.ToString();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: 7e9afb637ef14ed4b34fd226298272d5
|
|
||||||
timeCreated: 1776767993
|
|
||||||
@@ -21,8 +21,8 @@ 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")]
|
[SerializeField, InspectorReadOnly]
|
||||||
private CurrencyAmount InternalItemValue;
|
private double InternalItemValue;
|
||||||
|
|
||||||
public ItemType CurrentType
|
public ItemType CurrentType
|
||||||
{
|
{
|
||||||
@@ -84,6 +84,16 @@ namespace Fruitomation.Game.Items
|
|||||||
ItemInfo info = ItemInfoRegistry.Get(CurrentType);
|
ItemInfo info = ItemInfoRegistry.Get(CurrentType);
|
||||||
CurrentChild = Instantiate(info.Prefab, transform);
|
CurrentChild = Instantiate(info.Prefab, transform);
|
||||||
|
|
||||||
|
if (info.OverrideCost)
|
||||||
|
{
|
||||||
|
InternalItemValue = info.Cost;
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
{
|
||||||
|
InternalItemValue = Mathf.Pow((float)InternalItemValue, 1.1f);
|
||||||
|
}
|
||||||
|
|
||||||
CustomBehaviour = info.GetCustomBehaviour();
|
CustomBehaviour = info.GetCustomBehaviour();
|
||||||
if (CustomBehaviour is not null)
|
if (CustomBehaviour is not null)
|
||||||
{
|
{
|
||||||
@@ -143,7 +153,6 @@ namespace Fruitomation.Game.Items
|
|||||||
{
|
{
|
||||||
if (harvest)
|
if (harvest)
|
||||||
{
|
{
|
||||||
ItemInfo info = ItemInfoRegistry.Get(CurrentType);
|
|
||||||
MoneyController.Add(InternalItemValue);
|
MoneyController.Add(InternalItemValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -70,8 +70,9 @@ namespace Fruitomation.Game.Items
|
|||||||
|
|
||||||
[SerializeField] private CustomBehaviourType CustomBehaviour;
|
[SerializeField] private CustomBehaviourType CustomBehaviour;
|
||||||
|
|
||||||
|
public bool OverrideCost;
|
||||||
|
public double Cost;
|
||||||
public GameObject Prefab;
|
public GameObject Prefab;
|
||||||
public float BaseItemValue;
|
|
||||||
|
|
||||||
public CustomItemBehaviour GetCustomBehaviour()
|
public CustomItemBehaviour GetCustomBehaviour()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -9,11 +9,12 @@ namespace Fruitomation.Global
|
|||||||
private static MoneyController Instance;
|
private static MoneyController Instance;
|
||||||
|
|
||||||
[SerializeField, InspectorReadOnly("Current Money")]
|
[SerializeField, InspectorReadOnly("Current Money")]
|
||||||
private CurrencyAmount InternalCurrentMoney = new();
|
private double InternalCurrentMoney = new();
|
||||||
public static CurrencyAmount Current => Instance.InternalCurrentMoney;
|
public static double Current => Instance.InternalCurrentMoney;
|
||||||
|
|
||||||
public static void Add(CurrencyAmount amount)
|
public static void Add(double amount)
|
||||||
{
|
{
|
||||||
|
Instance.InternalCurrentMoney += amount;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Awake()
|
private void Awake()
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ namespace Fruitomation.UI
|
|||||||
[Header("Settings")]
|
[Header("Settings")]
|
||||||
[SerializeField] private BasicUpgrade Upgrade;
|
[SerializeField] private BasicUpgrade Upgrade;
|
||||||
[SerializeField] private bool DrawDefaultLines;
|
[SerializeField] private bool DrawDefaultLines;
|
||||||
[SerializeField] private CurrencyAmount Cost;
|
[SerializeField] private double Cost;
|
||||||
[SerializeField] private bool BigText;
|
[SerializeField] private bool BigText;
|
||||||
|
|
||||||
[Header("References")]
|
[Header("References")]
|
||||||
@@ -162,7 +162,7 @@ namespace Fruitomation.UI
|
|||||||
{
|
{
|
||||||
UpgradeState.Hidden => "???",
|
UpgradeState.Hidden => "???",
|
||||||
UpgradeState.Viewable => $"{formatted}",
|
UpgradeState.Viewable => $"{formatted}",
|
||||||
UpgradeState.Unlockable => $"{formatted}\n{Cost.AsString()}",
|
UpgradeState.Unlockable => $"{formatted}\n{Cost:F1}",
|
||||||
UpgradeState.Unlocked => $"{formatted}\nUnlocked",
|
UpgradeState.Unlocked => $"{formatted}\nUnlocked",
|
||||||
var _ => throw new ArgumentOutOfRangeException()
|
var _ => throw new ArgumentOutOfRangeException()
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ namespace Fruitomation.UI
|
|||||||
{
|
{
|
||||||
[Header("Settings")]
|
[Header("Settings")]
|
||||||
[SerializeField] private BuildingUnlock Building;
|
[SerializeField] private BuildingUnlock Building;
|
||||||
[SerializeField] private CurrencyAmount Cost;
|
[SerializeField] private double Cost;
|
||||||
|
|
||||||
[Header("References")]
|
[Header("References")]
|
||||||
[SerializeField] private Button AttachedButton;
|
[SerializeField] private Button AttachedButton;
|
||||||
@@ -30,7 +30,7 @@ namespace Fruitomation.UI
|
|||||||
|
|
||||||
AttachedText.text = unlocked
|
AttachedText.text = unlocked
|
||||||
? $"{formatted}\nUnlocked"
|
? $"{formatted}\nUnlocked"
|
||||||
: $"{formatted}\n{Cost.AsString()}";
|
: $"{formatted}\n{Cost:F1}";
|
||||||
|
|
||||||
AttachedButton.interactable = !unlocked;
|
AttachedButton.interactable = !unlocked;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ namespace Fruitomation.UI
|
|||||||
|
|
||||||
private void Update()
|
private void Update()
|
||||||
{
|
{
|
||||||
MoneyText.text = $"Current Money: {MoneyController.Current.AsString()}";
|
MoneyText.text = $"Current Money: {MoneyController.Current:F1}";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user