Items in an RPG generated in script (JS)

Hi all,

I am currently designing different items to use in my game like sword, shields etc. I am using a built in array to store all the items in, but I can only access it from the inspector. I am not sure how to create a typed array that can be modified in script. I could use a generic array or arraylist, but I am afraid that if I add too many items, it might become too slow. This is my item code:

static var items : Item[];

public class Item
{
	var name : String;
	var sellValue : int;
	var armorRate : int;
	var armorPierce : int;
	var critRate : int;
	var attackSpeed : int;
	var weaponRange : int;
	var minWeaponRange : int;
	
	
	function Item(nam : String, val : int, armor : int, armp : int, crit : int, attspd : int, rang : int, minrang :int)
	{
		name  = nam;
		armorRate = armor;
		sellValue = val;
		armorPierce = armp;
        critRate = crit;
        attackSpeed = attspd; 
        weaponRange = rang;
        minWeaponRange = minrang;
    }
}

What is the usual way of storing possible items in a game? Should I just add them all in the inspector or just use a generic array without type declared?

I just had to do the same thing and choose for a Custom Editor Window where I can chose the type to make, the mesh to spawn for it, ect… with a create button in the end to actually cast all the param to the right Type and instantiate the item.
Similar to what he does:

also don’t forget to serialize your custom classes or they won’t keep the values you set on Play… (assuming thats the same for C# and UnityScript)

It seems like a lot of work making a custom editor for something you only do once. I decided to store items in a seperate script that is attached to the main camera.

Thanks for the suggestion though.

depends on how many items you plan to have in your game. if even only over a 100, this comes in quite handy. and even so you will have to have a monobehaviour interface set the values of your custom class. so why not make a general one for all your classes derived from the baseclass Item, like consumable, weapon, potion,…
its actually less work then writing an inspector interface for each.