Added building unlock buttons
This commit is contained in:
@@ -9,20 +9,20 @@ using PashaBibko.Pacore.Attributes;
|
||||
|
||||
namespace Fruitomation.UI
|
||||
{
|
||||
public enum UpgradeState
|
||||
{
|
||||
Unlocked,
|
||||
Unlockable,
|
||||
Viewable,
|
||||
Hidden,
|
||||
}
|
||||
|
||||
public class BasicUpgradeButton : MonoBehaviour
|
||||
{
|
||||
[Serializable] private class LineInfo
|
||||
{
|
||||
public RectTransform[] LinePoints;
|
||||
}
|
||||
|
||||
private enum UpgradeState
|
||||
{
|
||||
Unlocked,
|
||||
Unlockable,
|
||||
Viewable,
|
||||
Hidden,
|
||||
}
|
||||
|
||||
[Header("Settings")]
|
||||
[SerializeField] private BasicUpgrade Upgrade;
|
||||
@@ -157,7 +157,7 @@ namespace Fruitomation.UI
|
||||
AttachedButton.interactable = State == UpgradeState.Unlockable;
|
||||
|
||||
// https://stackoverflow.com/questions/27040325/c-sharp-regex-to-convert-camelcase-to-sentence-case
|
||||
string formatted = Regex.Replace(Upgrade.ToString(), @"[A-Z]", " $0")[1..];
|
||||
string formatted = Regex.Replace(Upgrade.ToString(), "[A-Z]", " $0")[1..];
|
||||
AttachedText.text = State switch
|
||||
{
|
||||
UpgradeState.Hidden => "???",
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
using UnityEngine;
|
||||
|
||||
public class BuildiingUnlockButton : MonoBehaviour
|
||||
{
|
||||
// Start is called once before the first execution of Update after the MonoBehaviour is created
|
||||
void Start()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
31
Assets/Scripts/UI/BuildingUnlockButton.cs
Normal file
31
Assets/Scripts/UI/BuildingUnlockButton.cs
Normal file
@@ -0,0 +1,31 @@
|
||||
using System.Text.RegularExpressions;
|
||||
using Fruitomation.Game;
|
||||
using UnityEngine.UI;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Fruitomation.UI
|
||||
{
|
||||
public class BuildingUnlockButton : MonoBehaviour
|
||||
{
|
||||
[Header("Settings")]
|
||||
[SerializeField] private BuildingUnlock Building;
|
||||
[SerializeField] private CurrencyAmount Cost;
|
||||
|
||||
[Header("References")]
|
||||
[SerializeField] private Button AttachedButton;
|
||||
[SerializeField] private Text AttachedText;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
string formatted = Regex.Replace(Building.ToString(), "[A-Z]", " $0")[1..];
|
||||
AttachedText.text = formatted;
|
||||
|
||||
AttachedButton.onClick.AddListener(OnButtonClicked);
|
||||
}
|
||||
|
||||
private void OnButtonClicked()
|
||||
{
|
||||
UpgradeManager.Unlock(Building);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user