Foerming/Assets/Scripts/Item.cs
d-hain aacdd80fdf added Inventory UI
added logic to inventory
 * it is very possible to be reworked in the near future
 * With
   - ScriptableItem
   - an own Inventory class maybe
   - if necessary no Dictionary anymore
2022-05-19 02:30:21 +02:00

25 lines
809 B
C#

using System;
using UnityEngine;
//TODO: Auf ScriptableItem umschreiben!!!!!!!!!!
//
//https://www.youtube.com/watch?v=YLhj7SfaxSE
public class Item : MonoBehaviour, IComparable<Item> {
public readonly string displayName;
public readonly string description;
public readonly int id; //TODO: create an actual ID System that makes snens
public SpriteRenderer spriteRenderer;
public Sprite selectedSprite;
public Sprite defaultSprite;
public Item(string displayName, string description, int id) {
this.displayName = displayName;
this.description = description;
this.id = id;
spriteRenderer.sprite ??= defaultSprite; // defaultSprite is set in UnityEditor
}
public int CompareTo(Item other) {
return this.id - other.id;
}
}