mirror of
http://47.107.252.169:3000/Roguelite-Game-Developing-Team/Gen_Hack-and-Slash-Roguelite.git
synced 2025-11-20 00:57:14 +08:00
61 lines
1.8 KiB
C#
61 lines
1.8 KiB
C#
|
|
using Entity;
|
||
|
|
using TMPro;
|
||
|
|
using UnityEngine;
|
||
|
|
using UnityEngine.UI;
|
||
|
|
|
||
|
|
namespace UI
|
||
|
|
{
|
||
|
|
public abstract class ShopCardUI : MonoBehaviour
|
||
|
|
{
|
||
|
|
[SerializeField] protected TMP_Text label;
|
||
|
|
|
||
|
|
[SerializeField] protected Image icon;
|
||
|
|
|
||
|
|
[SerializeField] protected TMP_Text description;
|
||
|
|
|
||
|
|
[SerializeField] protected Button EnterButton;
|
||
|
|
|
||
|
|
public ShopUI shopUI;
|
||
|
|
|
||
|
|
private float labelTextOriginalY;
|
||
|
|
protected int ShoppingCost;
|
||
|
|
|
||
|
|
protected virtual void Awake()
|
||
|
|
{
|
||
|
|
labelTextOriginalY = label.transform.localPosition.y;
|
||
|
|
ShoppingCost=Configs.ConfigManager.Instance.GetValue<int>("ShoppingCost");
|
||
|
|
if(Program.Instance.FocusedEntity is Character character)
|
||
|
|
{
|
||
|
|
EnterButton.interactable = ShoppingCost <= character.Coin.Quantity;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
public abstract void Init();
|
||
|
|
|
||
|
|
protected void SetLabel(string text)
|
||
|
|
{
|
||
|
|
label.text = text;
|
||
|
|
switch (text.Length)
|
||
|
|
{
|
||
|
|
case > 6:
|
||
|
|
label.fontSize = 46;
|
||
|
|
label.transform.localPosition =
|
||
|
|
new Vector3(label.transform.localPosition.x, labelTextOriginalY + 7);
|
||
|
|
break;
|
||
|
|
case > 4:
|
||
|
|
label.fontSize = 46;
|
||
|
|
label.transform.localPosition = new Vector3(label.transform.localPosition.x, labelTextOriginalY);
|
||
|
|
break;
|
||
|
|
default:
|
||
|
|
label.fontSize = 62;
|
||
|
|
label.transform.localPosition = new Vector3(label.transform.localPosition.x, labelTextOriginalY);
|
||
|
|
break;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
public virtual void OnEnter()
|
||
|
|
{
|
||
|
|
shopUI?.OnHide();
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|