Made price of upgrade be required
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user