6-1. 7조 Item 구조

keubung·2024년 11월 26일
  1. IInteractable
public interface IInteractable
{
    public void Interact();
}
  1. BaseItem.cs
public abstract class BaseItem : Prop, IInteractable
{
    public ItemData ItemData;

    public enum ItemCarryType
    {
        Uncarryable,
        OneHanded,
        TwoHanded
    }

    public abstract void Interact();
}
  1. HandheldItem.cs
public class HandheldItem : BaseItem
{
    public override void Interact()
    {
    }
}
  1. ItemData.cs
public class ItemData
{
    public int Id { get; private set; }
    public string Name { get; private set; }
    public string Description { get; private set; }
    public ItemCarryType type { get; private set; }

    public ItemData(int id, string name, string description, ItemCarryType type)
    {
        Id = id;
        Name = name;
        Description = description;
        this.type = type;
    }
}
  1. TabletItem 등 HandheldItem의 아이템
public class TabletItem : HandheldItem
{
    public string TabletType { get; private set; }

    public override void Interact()
    {
    }
}
profile
김나영(Unity_6기)

0개의 댓글