mirror of
http://47.107.252.169:3000/Roguelite-Game-Developing-Team/Gen_Hack-and-Slash-Roguelite.git
synced 2025-11-20 09:57:13 +08:00
(client) feat:健康给予,路径优化,结算界面,商店界面 (#60)
Co-authored-by: m0_75251201 <m0_75251201@noreply.gitcode.com> Reviewed-on: http://47.107.252.169:3000/Roguelite-Game-Developing-Team/Gen_Hack-and-Slash-Roguelite/pulls/60
This commit is contained in:
61
Client/Assets/Scripts/UI/ShopCardUI.cs
Normal file
61
Client/Assets/Scripts/UI/ShopCardUI.cs
Normal file
@@ -0,0 +1,61 @@
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user