Esempio n. 1
0
    public void UseStart(GameObject user)
    {
        if (user == null || string.IsNullOrEmpty(triggerObjectName))
        {
            return;
        }

        Inventory userInventory = (Inventory)user.GetComponent <PlayerInventory>().playerInventory;

        if (userInventory != null)
        {
            ObjectPickup inventoryItem = userInventory.Remove(triggerObjectName);
            if (inventoryItem == null)
            {
                Debug.Log("Did not find " + triggerObjectName + " in your inventory");
                return;
            }

            if (!user.GetComponent <GhostController>().isGhost)
            {
                InventoryUIController uiInventory = (InventoryUIController)Transform.FindObjectOfType <InventoryUIController>();
                if (uiInventory != null)
                {
                    Debug.Log("Found InventoryUIController");
                    uiInventory.RemoveFromInventoryPanel(inventoryItem);
                }
            }

            // inventoryItem.gameObject.SetActive(true);
            // inventoryItem.transform.position = new Vector3(transform.position.x, transform.position.y, transform.position.z - 1f);
            Debug.Log("--- objectInventory ---");
            objectInventory.Add(inventoryItem);
            objectInventory.LogInventory();
        }
    }