Improved upgrade menu look

This commit is contained in:
Pasha Bibko
2026-04-21 13:58:28 +01:00
parent 34f2169607
commit c930588071
12 changed files with 826 additions and 241 deletions

View File

@@ -4,6 +4,7 @@ using UnityEngine.UI;
using UnityEngine;
using System.Linq;
using System;
using System.Text.RegularExpressions;
namespace Fruitomation.UI
{
@@ -24,8 +25,9 @@ namespace Fruitomation.UI
[Header("Settings")]
[SerializeField] private BasicUpgrade Upgrade;
[SerializeField] private int UpgradeCost;
[SerializeField] private bool DrawDefaultLines;
[SerializeField] private CurrencyAmount Cost;
[SerializeField] private bool BigText;
[Header("References")]
[SerializeField] private BasicUpgradeButton[] RequiredUpgrades;
@@ -43,6 +45,8 @@ namespace Fruitomation.UI
private void Awake()
{
AttachedText = gameObject.GetComponentInChildren<Text>();
AttachedText.fontSize = 30;
AttachedButton = GetComponent<Button>();
AttachedButton.onClick.AddListener(() => { UpgradeManager.Unlock(Upgrade); });
@@ -63,6 +67,7 @@ namespace Fruitomation.UI
LineRenderer lr = go.AddComponent<LineRenderer>();
lr.material = LineMaterial;
lr.widthMultiplier = 0.1f;
lr.positionCount = 2;
lines.Add((lr, required, null));
@@ -81,6 +86,7 @@ namespace Fruitomation.UI
LineRenderer lr = go.AddComponent<LineRenderer>();
lr.material = LineMaterial;
lr.widthMultiplier = 0.1f;
lines.Add((lr, null, line));
}
@@ -138,11 +144,11 @@ namespace Fruitomation.UI
State = UpgradeState.Hidden;
}
//
// https://stackoverflow.com/questions/27040325/c-sharp-regex-to-convert-camelcase-to-sentence-case
string formatted = Regex.Replace(Upgrade.ToString(), @"[A-Z]", " $0");
AttachedText.text = State == UpgradeState.Hidden
? "???"
: $"{Upgrade.ToString()} [{UpgradeCost}]";
: $"{formatted}\n{Cost.AsString()}";
}
private bool IsUnlocked => State == UpgradeState.Unlocked;