您最多选择25个主题
主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
52 行
805 B
52 行
805 B
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
public class CollectibleItem : MonoBehaviour
|
|
{
|
|
|
|
[SerializeField]
|
|
private Item currentItem;
|
|
|
|
[SerializeField]
|
|
private SpriteRenderer[] itemImages;
|
|
private void Start()
|
|
{
|
|
SetItem();
|
|
}
|
|
|
|
public void PickedItem()
|
|
{
|
|
|
|
|
|
}
|
|
|
|
public Item GetItem()
|
|
{
|
|
Debug.Log("current item " + currentItem);
|
|
return currentItem;
|
|
|
|
}
|
|
|
|
//this function is only for testing
|
|
public void SetItem()
|
|
{
|
|
for (int i = 0; i < itemImages.Length; i++)
|
|
{
|
|
itemImages[i].sprite = currentItem.PreviewImage;
|
|
}
|
|
|
|
}
|
|
public void OnTriggerEnter(Collider other)
|
|
{
|
|
if (other.tag == "Player")
|
|
{
|
|
if (other.gameObject.GetComponent<ItemPicker>())
|
|
{
|
|
|
|
other.gameObject.GetComponent<ItemPicker>().PickItem(currentItem);
|
|
|
|
}
|
|
|
|
}
|
|
}
|
|
}
|