예제 #1
0
    public void PickUp(GameObject item)
    {
        int i = FirstEmptySlot();

        if (i >= 0)
        {
            inventoryUI.AddToSlot(i, item.GetComponent <Collectible>().sprite);

            // Add item to the items array
            items[i] = item;

            //updates item list to add item to list
            GlobalItemList.UpdateItemList(item.name,
                                          "Inventory",
                                          new Vector3(i, 0, 0),
                                          "Player");

            // Remove item from the world
            item.SetActive(false);

            // If you pick up these items, that means the player has them.
            // Update globalControlsProperties accordingly.
            if (item.name.Equals("Water Bottle Clean(Clone)"))
            {
                Debug.Log("Player Has Water!");
                GlobalControls.globalControlsProperties.Add("playerHasCleanWater");
            }

            if (item.name.Equals("Wrench(Clone)"))
            {
                Debug.Log("Player Has Wrench!");
                GlobalControls.globalControlsProperties.Add("playerHasWrench");
            }

            if (item.name.Equals("First Aid Kit(Clone)"))
            {
                Debug.Log("Player Has First Aid Kit!");
                GlobalControls.globalControlsProperties.Add("playerHasFirstAidKit");
            }

            if (item.name.Equals("Epi Pen(Clone)"))
            {
                Debug.Log("Player Has Epi Pen!");
                GlobalControls.globalControlsProperties.Add("playerHasEpiPen");
            }
        }
        //reselect slot to current slot number to update tooltip if necessary
        SelectSlotNumber(selectedSlotNumber);
    }