コード例 #1
0
    void Start()
    {
        invObject = GetComponent <InventoryObj>();
        invObject.changeID(ID);

        Debug.Log(invObject.ReturnName());
        Debug.Log(invObject.ReturnDescription());
    }
コード例 #2
0
    public void changeID(int newID)
    {
        objID = newID;

        InventoryObj obj = getObj(newID);

        objName     = obj.ReturnName();
        description = obj.ReturnDescription();
    }
コード例 #3
0
    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.");
    }
コード例 #4
0
    public void removeObj(InventoryObj obj)
    {
        for (int i = 0; i < inventory.Count; i++)
        {
            if (inventory[i].ReturnID() == obj.ReturnID())
            {
                inventory.Remove(inventory[i]);

                break;
            }
        }
    }
コード例 #5
0
    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);
    }
コード例 #6
0
    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)));
    }
コード例 #7
0
    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);
    }
コード例 #8
0
    public static InventoryObj getInventoryObject(GameObject obj)
    {
        InventoryObj objInv = obj.GetComponent <InventoryObj>();

        return(objInv);
    }