void Start() { invObject = GetComponent <InventoryObj>(); invObject.changeID(ID); Debug.Log(invObject.ReturnName()); Debug.Log(invObject.ReturnDescription()); }
public void changeID(int newID) { objID = newID; InventoryObj obj = getObj(newID); objName = obj.ReturnName(); description = obj.ReturnDescription(); }
public Text menu; //expiremental public void addObj(InventoryObj obj) { //Debug.Log("The name of this item is " + obj.ReturnName()); Debug.Log("Targeting " + obj.ReturnName()); inventory.Add(obj); Debug.Log(obj.ReturnName() + " added to inventory."); }
public void removeObj(InventoryObj obj) { for (int i = 0; i < inventory.Count; i++) { if (inventory[i].ReturnID() == obj.ReturnID()) { inventory.Remove(inventory[i]); break; } } }
public bool doesContain(InventoryObj obj) { bool result = false; for (int i = 0; i < inventory.Count; i++) { if (inventory[i].ReturnID() == obj.ReturnID()) { result = true; } } return(result); }
public void openDoor(Inventory playerInventory) { if (playerInventory.doesContain(InventoryObj.getObj(neededObj))) { Debug.Log(playerInventory.doesContain(InventoryObj.getObj(neededObj))); playerInventory.removeObj(InventoryObj.getObj(neededObj)); //Removes the object from inventory self.enabled = false; isOpen = true; anim.SetBool("isOpen", isOpen); Debug.Log("Opened door."); } Debug.Log(playerInventory.doesContain(InventoryObj.getObj(neededObj))); }
public static InventoryObj Registry(int objID) { InventoryObj invObject = myObj; string objName; string objDescript; Texture2D objImage; if (objID == 0) //If there is a rarity system, do it so that each nth number is x rarity { objName = "Electrolytic Capacitor"; objDescript = "A small capacitor that stores pulses of energy. Has high capacitance but isn't the most efficient storage device..."; objImage = Resources.Load("Electrolytic Capacitor.png") as Texture2D; invObject = new InventoryObj(objName, objDescript, objID, objImage); } else if (objID == 1) //If there is a rarity system, do it so that each nth number is x rarity { objName = "Ceramic Capacitor"; objDescript = "A small capacitor that stores pulses of energy. Has low and somewhat unstable capacitance, but are efficient enough to have a myriad of uses."; objImage = Resources.Load("Ceramic Capacitor.png") as Texture2D; invObject = new InventoryObj(objName, objDescript, objID, objImage); } else if (objID == 2) //If there is a rarity system, do it so that each nth number is x rarity { objName = "Key Card: Clearance Level C"; objDescript = "A security key card with the lowest level of clearance. Grants access to warehouses and rooms available to low-ranking factory workers."; objImage = Resources.Load("Key Card.png") as Texture2D; invObject = new InventoryObj(objName, objDescript, objID, objImage); } return(invObject); }
public static InventoryObj getInventoryObject(GameObject obj) { InventoryObj objInv = obj.GetComponent <InventoryObj>(); return(objInv); }