Files
DougDiggem/Assets/Scripts/Item.cs
T

58 lines
1.6 KiB
C#

using System.Runtime.InteropServices.WindowsRuntime;
using UnityEngine;
// This is the actual ITEM data structure for keeping track of inventory/item actions
public class Item
{
public string itemName;
public ItemIdEnum id;
public int maxStack = 10;
public string description = "";
public string itemImagePath = "";
public Item(string itemName, ItemIdEnum id, int maxStack, string description, string itemImagePath)
{
this.itemName = itemName;
this.id = id;
this.maxStack = maxStack;
this.description = description;
this.itemImagePath = itemImagePath;
}
public Item(ItemIdEnum id)
{
Item newItem = ItemUtilities.GetItemFromId(id);
this.itemName = newItem.itemName;
this.id = newItem.id;
this.maxStack = newItem.maxStack;
this.description = newItem.description;
this.itemImagePath= newItem.itemImagePath;
}
}
public enum ItemIdEnum
{
NONE = 0,
STAR_SHARD = 1
}
public static class ItemUtilities
{
// THIS IS WHERE ALL THE ITEMS ARE DEFINED
public static Item GetItemFromId(ItemIdEnum itemId)
{
switch (itemId)
{
case ItemIdEnum.STAR_SHARD:
return new Item(
itemName: "Star Shard",
id: itemId,
maxStack: 10,
description: "A rare material that can only be found here in the valley.",
itemImagePath: "ItemSprites/starShard");
}
return new Item("", itemId, 0, "", "ItemSprites/noneItem"); ;
}
}