You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
40 lines
845 B
40 lines
845 B
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
public class Slot : MonoBehaviour
|
|
{
|
|
public int slotIndex; // 物品在背包中的下标
|
|
public Item slotItem;
|
|
public Image slotImage;
|
|
public Text slotNum;
|
|
public string slotInfo;
|
|
|
|
public GameObject itemInSlot;
|
|
|
|
public void ItemOnClicked()
|
|
{
|
|
InventoryManager.UpdateItemInfo(slotInfo);
|
|
InventoryManager.UpdateItemIndex(slotIndex);
|
|
}
|
|
|
|
public void SetupSlot(Item item)
|
|
{
|
|
if(item == null)
|
|
{
|
|
itemInSlot.SetActive(false);
|
|
return;
|
|
}
|
|
|
|
slotImage.sprite = item.itemImage;
|
|
slotNum.text = item.itemHeld.ToString();
|
|
slotInfo = item.itemInfo;
|
|
}
|
|
|
|
public void Use()
|
|
{
|
|
InventoryManager.UseItem();
|
|
}
|
|
}
|