예제 #1
0
    //Puts a pocketable item in the player's inventory
    public void AddItemToInventory(Pocketable item)
    {
        //If player currently has an item in their inventory, remove it
        if (pocketedItem != null)
        {
            RemoveItemFromInventory();
        }

        //Set new pocketed item
        pocketedItem = item;

        //Handle UI for playable characters
        if (!(this is Agent))
        {
            inventoryUI.AddItem(item);
        }

        item.GetComponent <PhotonView>().RPC("SetItemPocketConditions", RpcTarget.All);
    }
예제 #2
0
    //Removes the current item from the player's inventory
    public void RemoveItemFromInventory(bool resetConditions = true)
    {
        //If player does not currently have an item in their inventory, exit the function
        if (pocketedItem == null)
        {
            return;
        }

        //If resetConditions is true then we drop the item next to the player
        //otherwise we simply remove the item from the players inventory
        if (resetConditions)
        {
            pocketedItem.SetItemDropConditions(transform.position);

            //if the item has a sub task then disable the task marker
            //for the item with the master task
            if (pocketedItem.task != null && pocketedItem.task.parent != null)
            {
                pocketedItem.task.parent.GetComponent <Interactable>().DisableTaskMarker();
            }
        }

        //Uncomplete the item's task if there was one
        if (pocketedItem.task != null && pocketedItem.task.IsRequired())
        {
            pocketedItem.task.Uncomplete();
        }

        //handle UI for playable characters
        if (!(this is Agent))
        {
            inventoryUI.RemoveItem();
        }

        pocketedItem = null;
    }
예제 #3
0
 /// <summary> Adds an item to the player inventory in the UI. </summary>
 public void AddItem(Pocketable item)
 {
     inventoryImage.gameObject.SetActive(true);
     inventoryImage.texture = item.image;
 }