Made price of upgrade be required

This commit is contained in:
Pasha Bibko
2026-04-28 16:22:12 +01:00
parent 631d5691ff
commit 0ccf979869
5 changed files with 161 additions and 175 deletions

View File

@@ -1,5 +1,6 @@
using System.Text.RegularExpressions;
using Fruitomation.Game;
using Fruitomation.Global;
using UnityEngine.UI;
using UnityEngine;
@@ -28,16 +29,26 @@ namespace Fruitomation.UI
string formatted = Regex.Replace(Building.ToString(), "[A-Z]", " $0")[1..];
bool unlocked = UpgradeManager.Is(Building);
string cost = Cost == 0f ? "UNAVAILABLE" : $"{Cost:F1}";
AttachedText.text = unlocked
? $"{formatted}\nUnlocked"
: $"{formatted}\n{Cost:F1}";
: $"{formatted}\n{cost}";
AttachedButton.interactable = !unlocked;
}
private void OnButtonClicked()
{
UpgradeManager.Unlock(Building);
if (Cost == 0f)
{
Debug.LogWarning("Upgrade Cost has not been set");
return;
}
if (MoneyController.CanBuy(Cost))
{
UpgradeManager.Unlock(Building);
}
}
}
}