Made price of upgrade be required
This commit is contained in:
@@ -5,6 +5,7 @@ using UnityEngine.UI;
|
||||
using UnityEngine;
|
||||
using System.Linq;
|
||||
using System;
|
||||
using Fruitomation.Global;
|
||||
using PashaBibko.Pacore.Attributes;
|
||||
|
||||
namespace Fruitomation.UI
|
||||
@@ -101,7 +102,16 @@ namespace Fruitomation.UI
|
||||
|
||||
private void OnButtonClicked()
|
||||
{
|
||||
UpgradeManager.Unlock(Upgrade);
|
||||
if (Cost == 0f)
|
||||
{
|
||||
Debug.LogWarning("Upgrade Cost has not been set");
|
||||
return;
|
||||
}
|
||||
|
||||
if (MoneyController.CanBuy(Cost))
|
||||
{
|
||||
UpgradeManager.Unlock(Upgrade);
|
||||
}
|
||||
}
|
||||
|
||||
private bool IsUnlockable =>
|
||||
@@ -156,13 +166,15 @@ namespace Fruitomation.UI
|
||||
|
||||
AttachedButton.interactable = State == UpgradeState.Unlockable;
|
||||
|
||||
string cost = Cost == 0f ? "UNAVAILABLE" : $"{Cost:F1}";
|
||||
|
||||
// https://stackoverflow.com/questions/27040325/c-sharp-regex-to-convert-camelcase-to-sentence-case
|
||||
string formatted = Regex.Replace(Upgrade.ToString(), "[A-Z]", " $0")[1..];
|
||||
AttachedText.text = State switch
|
||||
{
|
||||
UpgradeState.Hidden => "???",
|
||||
UpgradeState.Viewable => $"{formatted}",
|
||||
UpgradeState.Unlockable => $"{formatted}\n{Cost:F1}",
|
||||
UpgradeState.Unlockable => $"{formatted}\n{cost}",
|
||||
UpgradeState.Unlocked => $"{formatted}\nUnlocked",
|
||||
var _ => throw new ArgumentOutOfRangeException()
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user