Files
DougDiggem/Assets/Scripts/WorldInteraction/Item.cs
T

73 lines
2.1 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 bool throwable = false;
public Item(string itemName, ItemIdEnum id, int maxStack, string description, string itemImagePath, bool throwable = false)
{
this.itemName = itemName;
this.id = id;
this.maxStack = maxStack;
this.description = description;
this.itemImagePath = itemImagePath;
this.throwable = throwable;
}
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;
this.throwable = newItem.throwable;
}
}
public enum ItemIdEnum
{
NONE = 0,
STAR_SHARD = 1,
DYNAMITE = 2
}
[System.Serializable]
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",
false);
case ItemIdEnum.DYNAMITE:
return new Item(
itemName: "Dynamite",
id: itemId,
maxStack: 10,
description: "A throwable red stick that goes BOOM (after a short time).",
itemImagePath: "ItemSprites/dynamite",
true);
}
return new Item("", itemId, 0, "", "ItemSprites/noneItem");
}
}