Added project
This commit is contained in:
30
Platformer/Assets/Scripts/ItemComponent.cs
Normal file
30
Platformer/Assets/Scripts/ItemComponent.cs
Normal file
@@ -0,0 +1,30 @@
|
||||
using UnityEngine;
|
||||
|
||||
public class ItemComponent : MonoBehaviour, IObjectDestroyer {
|
||||
|
||||
[SerializeField] private ItemType type;
|
||||
[SerializeField] private SpriteRenderer spriteRenderer;
|
||||
[SerializeField] private Animator animator;
|
||||
|
||||
private Item _item;
|
||||
|
||||
public Item Item => _item;
|
||||
|
||||
private void Start() {
|
||||
_item = GameManager.Instance.ItemBase.GetItemOfId((int) type);
|
||||
spriteRenderer.sprite = _item.Icon;
|
||||
GameManager.Instance.itemsContainer.Add(gameObject, this);
|
||||
}
|
||||
|
||||
public void Destroy(GameObject gameObj) {
|
||||
animator.SetTrigger("StartDestroy");
|
||||
}
|
||||
|
||||
public void EndDestroy() {
|
||||
MonoBehaviour.Destroy(gameObject);
|
||||
}
|
||||
}
|
||||
|
||||
public enum ItemType {
|
||||
ForcePotion = 0, DamagePotion = 1, ArmorPotion = 2
|
||||
}
|
||||
Reference in New Issue
Block a user