mirror of
http://47.107.252.169:3000/Roguelite-Game-Developing-Team/Gen_Hack-and-Slash-Roguelite.git
synced 2025-11-20 05:37:11 +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:
57
Client/Assets/Scripts/UI/ShopUI.cs
Normal file
57
Client/Assets/Scripts/UI/ShopUI.cs
Normal file
@@ -0,0 +1,57 @@
|
||||
using Base;
|
||||
using Entity;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace UI
|
||||
{
|
||||
public class ShopUI : FullScreenUI
|
||||
{
|
||||
public Transform cardsParent;
|
||||
|
||||
public ShopCardUI[] cardPrefabs;
|
||||
|
||||
public Button refreshButton;
|
||||
|
||||
public override void Show()
|
||||
{
|
||||
base.Show();
|
||||
if (Program.Instance.FocusedEntity is Character character)
|
||||
{
|
||||
var cost = Configs.ConfigManager.Instance.GetValue<int>("OpenShopCost");
|
||||
refreshButton.interactable = character.Coin.Quantity >= cost;
|
||||
}
|
||||
if (cardsParent.childCount <= 1)
|
||||
{
|
||||
Refresh();
|
||||
}
|
||||
// Refresh();
|
||||
}
|
||||
|
||||
public void Refresh(int count = 3)
|
||||
{
|
||||
ClearCards();
|
||||
if (cardPrefabs == null || cardPrefabs.Length == 0)
|
||||
return;
|
||||
for (var i = 0; i < count; i++)
|
||||
{
|
||||
var index = Random.Range(0, cardPrefabs.Length);
|
||||
var card = cardPrefabs[index];
|
||||
var newCard = Instantiate(card, cardsParent);
|
||||
newCard.shopUI = this;
|
||||
newCard.Init();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void ClearCards()
|
||||
{
|
||||
foreach (Transform card in cardsParent) Destroy(card.gameObject);
|
||||
}
|
||||
|
||||
public void OnHide()
|
||||
{
|
||||
UIInputControl.Instance.Hide(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user