mirror of
http://47.107.252.169:3000/Roguelite-Game-Developing-Team/Gen_Hack-and-Slash-Roguelite.git
synced 2025-11-20 05:27: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:
43
Client/Assets/Scripts/UI/ShopCardUIItem.cs
Normal file
43
Client/Assets/Scripts/UI/ShopCardUIItem.cs
Normal file
@@ -0,0 +1,43 @@
|
||||
using System.Linq;
|
||||
using Data;
|
||||
using Entity;
|
||||
using Item;
|
||||
using Managers;
|
||||
using UnityEngine;
|
||||
|
||||
namespace UI
|
||||
{
|
||||
public class ShopCardUIItem : ShopCardUI
|
||||
{
|
||||
private ItemResource itemResource;
|
||||
|
||||
public override void Init()
|
||||
{
|
||||
var itemList = DefineManager.Instance.QueryDefinesByType<ItemDef>();
|
||||
if (!itemList.Any())
|
||||
return;
|
||||
var index = Random.Range(0, itemList.Length);
|
||||
var item = ItemResourceManager.Instance.GetItem(itemList[index]);
|
||||
Init(item);
|
||||
}
|
||||
|
||||
public void Init(ItemResource item)
|
||||
{
|
||||
if (item.Icon.Any())
|
||||
icon.sprite = item.Icon[0];
|
||||
itemResource = item;
|
||||
SetLabel(item.Name);
|
||||
description.text = item.Description;
|
||||
|
||||
}
|
||||
|
||||
public override void OnEnter()
|
||||
{
|
||||
base.OnEnter();
|
||||
if(Program.Instance.FocusedEntity is Character character)
|
||||
{
|
||||
character.TryPickupItem(itemResource, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user