Hi all, my script here is supposed to act as a store where players can buy and sell items.
Store.js
import System.Collections.Generic;
var x : int;
var cnt : int;
var Player;
var InventoryArray;
var Inventory;
var gold;
var showGUI = false;
var showarmorGUI = false;
var showweaponsGUI = false;
var showmiscGUI = false;
var storeInventory = new List.<Item>();
var Items : Items;
var playerInventory;
//private var playerInventory : InventoryList; // reference to the inventory
function Start() {
playerInventory = GameObject.Find("GUIElements").GetComponent("Inventory").inventory;
for(cnt = 0; cnt < x; cnt++) {
storeInventory.Add(Items.StoreInventory1[cnt]); <<<ERROR OCCURS HERE
}
}
function OnGUI() {
if(showGUI == true) {
GUI.Box(Rect(60,60,265,30),"Welcome, stranger. What can I get for you?");
if(GUI.Button(Rect(60,90,60,45),"Armor")){
showarmorGUI = true;
}
if(GUI.Button(Rect(60,135,60,45),"Weapons")){
showweaponsGUI = true;
}
if(GUI.Button(Rect(60,180,60,45),"Misc")){
showmiscGUI = true;
}
}
Item.js
enum Rarity{Common, Uncommon, Rare, Beastly, Insane, Epic, Legendary, Null}
enum ArmorSlots{Head, Neck, Shoulders, Arms, Forearms, Hands, Torso, Waist, Legs, Feet, Null}
enum JewelrySlots{Ear1, Ear2, Neck, Wrist, Finger1, Finger2, Finger3, Finger4, Finger5, Finger6, Finger7, Finger8, Finger9, Finger10, Null}
enum WeaponSlot{Primary, Secondary, Ranged, Null}
enum WeaponSlot2{Primary, Secondary, Ranged, Null}
//var name1 : String;
//var _value : int;
var name2 : String;
var description : String;
var rarity : Rarity;
var price : int;
var armorSlot : ArmorSlots;
var jewelSlot : JewelrySlots;
var weaponSlot : WeaponSlot;
var weaponSlot2 : WeaponSlot2;
var curDura : int;
var maxDura : int;
var icon : Texture2D;
function Start() {
}
class Item {
function Item(_name2,_description,_rarity,_armorSlot,_weaponSlot,_weaponSlot2,_jewelSlot,_curDura,_maxDura,_icon,_price) {
item_name2 = _name2;
item_description = _description;
item_rarity = _rarity;
item_armorSlot = _armorSlot;
item_weaponSlot = _weaponSlot;
item_weaponSlot2 = _weaponSlot2;
item_jewelSlot = _jewelSlot;
item_curDura = _curDura;
item_maxDura = _maxDura;
item_icon = _icon;
item_price = _price;
//item_rarity = Rarity.Rare;
//item_maxdura = maxDura;
//item_curdura = curDura;
}
}
Items.js
import System.Collections.Generic;
var sellList : Item;
var cnt : int;
var StoreInventory1 = new List.<Item>();
var my_item : Item; //= new Item("posion",360);
var my_item1 : Item; //= new Item("posion",360);
function Start() {
StoreInventory1.Add(my_item);
StoreInventory1.Add(my_item1);
}
So as you can see the storeInventory list should be populated with everything contained in the StoreInventory1 list in Items.js
However, I am getting an Argument is out of range exception on the line I marked in the Store.js script. Can anyone take a quick look and see what I might be doing wrong? Thank you!