Determining item types

For starters, we will concentrate on some of the basic item types that we would like to define in our game, such as weapons, armor, and clothing. On top of this, we can also add health packets, potions, and collectibles.

We will create three new scripts named BaseItem.cs, InventoryItem.c, and InventorySystem.cs. The BaseItem class will hold the generic properties for all items, just like the BaseCharacter class we defined previously. The InventoryItem class will inherit the BaseItem class and define the item type.

A listing of BaseItem.cs is as follows:

using System;using UnityEngine;namespace com.noorcon.rpg2e{[Serializable]public class BaseItem{public enum ItemCatrgory{Weapon = 0,Armour = 1,Clothing = 2,Health = 3, ...

Get Building an RPG with Unity 2018 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.