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")]
|
||||
private ItemType InternalItemType = ItemType.None;
|
||||
|
||||
[SerializeField, InspectorReadOnly("Item Value")]
|
||||
private CurrencyAmount InternalItemValue;
|
||||
[SerializeField, InspectorReadOnly]
|
||||
private double InternalItemValue;
|
||||
|
||||
public ItemType CurrentType
|
||||
{
|
||||
@@ -84,6 +84,16 @@ namespace Fruitomation.Game.Items
|
||||
ItemInfo info = ItemInfoRegistry.Get(CurrentType);
|
||||
CurrentChild = Instantiate(info.Prefab, transform);
|
||||
|
||||
if (info.OverrideCost)
|
||||
{
|
||||
InternalItemValue = info.Cost;
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
InternalItemValue = Mathf.Pow((float)InternalItemValue, 1.1f);
|
||||
}
|
||||
|
||||
CustomBehaviour = info.GetCustomBehaviour();
|
||||
if (CustomBehaviour is not null)
|
||||
{
|
||||
@@ -143,7 +153,6 @@ namespace Fruitomation.Game.Items
|
||||
{
|
||||
if (harvest)
|
||||
{
|
||||
ItemInfo info = ItemInfoRegistry.Get(CurrentType);
|
||||
MoneyController.Add(InternalItemValue);
|
||||
}
|
||||
|
||||
|
||||
@@ -70,8 +70,9 @@ namespace Fruitomation.Game.Items
|
||||
|
||||
[SerializeField] private CustomBehaviourType CustomBehaviour;
|
||||
|
||||
public bool OverrideCost;
|
||||
public double Cost;
|
||||
public GameObject Prefab;
|
||||
public float BaseItemValue;
|
||||
|
||||
public CustomItemBehaviour GetCustomBehaviour()
|
||||
{
|
||||
|
||||
@@ -9,11 +9,12 @@ namespace Fruitomation.Global
|
||||
private static MoneyController Instance;
|
||||
|
||||
[SerializeField, InspectorReadOnly("Current Money")]
|
||||
private CurrencyAmount InternalCurrentMoney = new();
|
||||
public static CurrencyAmount Current => Instance.InternalCurrentMoney;
|
||||
private double InternalCurrentMoney = new();
|
||||
public static double Current => Instance.InternalCurrentMoney;
|
||||
|
||||
public static void Add(CurrencyAmount amount)
|
||||
public static void Add(double amount)
|
||||
{
|
||||
Instance.InternalCurrentMoney += amount;
|
||||
}
|
||||
|
||||
private void Awake()
|
||||
|
||||
@@ -27,7 +27,7 @@ namespace Fruitomation.UI
|
||||
[Header("Settings")]
|
||||
[SerializeField] private BasicUpgrade Upgrade;
|
||||
[SerializeField] private bool DrawDefaultLines;
|
||||
[SerializeField] private CurrencyAmount Cost;
|
||||
[SerializeField] private double Cost;
|
||||
[SerializeField] private bool BigText;
|
||||
|
||||
[Header("References")]
|
||||
@@ -162,7 +162,7 @@ namespace Fruitomation.UI
|
||||
{
|
||||
UpgradeState.Hidden => "???",
|
||||
UpgradeState.Viewable => $"{formatted}",
|
||||
UpgradeState.Unlockable => $"{formatted}\n{Cost.AsString()}",
|
||||
UpgradeState.Unlockable => $"{formatted}\n{Cost:F1}",
|
||||
UpgradeState.Unlocked => $"{formatted}\nUnlocked",
|
||||
var _ => throw new ArgumentOutOfRangeException()
|
||||
};
|
||||
|
||||
@@ -9,7 +9,7 @@ namespace Fruitomation.UI
|
||||
{
|
||||
[Header("Settings")]
|
||||
[SerializeField] private BuildingUnlock Building;
|
||||
[SerializeField] private CurrencyAmount Cost;
|
||||
[SerializeField] private double Cost;
|
||||
|
||||
[Header("References")]
|
||||
[SerializeField] private Button AttachedButton;
|
||||
@@ -30,7 +30,7 @@ namespace Fruitomation.UI
|
||||
|
||||
AttachedText.text = unlocked
|
||||
? $"{formatted}\nUnlocked"
|
||||
: $"{formatted}\n{Cost.AsString()}";
|
||||
: $"{formatted}\n{Cost:F1}";
|
||||
|
||||
AttachedButton.interactable = !unlocked;
|
||||
}
|
||||
|
||||
@@ -56,7 +56,7 @@ namespace Fruitomation.UI
|
||||
|
||||
private void Update()
|
||||
{
|
||||
MoneyText.text = $"Current Money: {MoneyController.Current.AsString()}";
|
||||
MoneyText.text = $"Current Money: {MoneyController.Current:F1}";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user