public Item_Root CreateInstanceOfItem(string id) { if (Item_Root.GetItemByID(id) != null) { return((Item_Root)Item_Root.GetItemByID(id).MemberwiseClone()); } else { Debug.LogError("Could not find a definition for '" + id + "' to create an instance of."); return(null); } }
private void GenerateShopInventoriesFromJSON() { for (int i = 0; i < _worldData["ShopInventories"].Count; i++) { JSONObject entry = _worldData["ShopInventories"][i]; JSONObject item1o = entry["item1"]; JSONObject item2o = entry["item2"]; JSONObject item3o = entry["item3"]; JSONObject item4o = entry["item4"]; Item_Root item1 = null; Item_Root item2 = null; Item_Root item3 = null; Item_Root item4 = null; if (item1o != null) { item1 = Item_Root.GetItemByID(item1o.str); } if (item2o != null) { item2 = Item_Root.GetItemByID(item2o.str); } if (item3o != null) { item3 = Item_Root.GetItemByID(item3o.str); } if (item4o != null) { item4 = Item_Root.GetItemByID(item4o.str); } new Resources_InventoryShop(entry["id"].str, item1, item2, item3, item4); } }
private void GenerateStartingInventoriesFromJSON() { for (int i = 0; i < _worldData["StartingInventories"].Count; i++) { JSONObject entry = _worldData["StartingInventories"][i]; JSONObject gunInfo = entry["gun"]; JSONObject meleeInfo = entry["melee"]; JSONObject clothesInfo = entry["clothes"]; JSONObject shoesInfo = entry["shoes"]; JSONObject pinInfo = entry["pin"]; JSONObject neckInfo = entry["neck"]; JSONObject ringInfo = entry["ring"]; JSONObject wristInfo = entry["wrist"]; JSONObject hairInfo = entry["hair"]; JSONObject flowerInfo = entry["flower"]; Item_Weapon_Gun gun = null; Item_Weapon_Melee melee = null; Item_Gear_Clothes clothes = null; Item_Gear_Shoes shoes = null; Item_Gear_Pin pin = null; Item_Gear_Neck neck = null; Item_Gear_Ring ring = null; Item_Gear_Wrist wrist = null; Item_Decay_Hair hair = null; Item_Decay_Flower flower = null; if (gunInfo != null) { gun = (Item_Weapon_Gun)Item_Root.GetItemByID(gunInfo.str); } if (meleeInfo != null) { melee = (Item_Weapon_Melee)Item_Root.GetItemByID(meleeInfo.str); } if (clothesInfo != null) { clothes = (Item_Gear_Clothes)Item_Root.GetItemByID(clothesInfo.str); } if (shoesInfo != null) { shoes = (Item_Gear_Shoes)Item_Root.GetItemByID(shoesInfo.str); } if (pinInfo != null) { pin = (Item_Gear_Pin)Item_Root.GetItemByID(pinInfo.str); } if (neckInfo != null) { neck = (Item_Gear_Neck)Item_Root.GetItemByID(neckInfo.str); } if (ringInfo != null) { ring = (Item_Gear_Ring)Item_Root.GetItemByID(ringInfo.str); } if (wristInfo != null) { wrist = (Item_Gear_Wrist)Item_Root.GetItemByID(wristInfo.str); } if (hairInfo != null) { hair = (Item_Decay_Hair)Item_Root.GetItemByID(hairInfo.str); } if (flowerInfo != null) { flower = (Item_Decay_Flower)Item_Root.GetItemByID(flowerInfo.str); } Resources_Inventory inventory = new Resources_Inventory(entry["id"].str, gun, melee, clothes, shoes, pin, neck, ring, wrist, hair, flower); } }