Пример #1
0
    void putItem(Transform selectedItem, float offSetY, Vector3 fixedPos)
    {
        GameObject dropItem = (GameObject)Instantiate(selectedItem.GetComponent <ItemOnObject>().item.itemModel);
        Item       item     = itemDataBase.getItemByID(selectedItem.GetComponent <ItemOnObject> ().item.itemID);

        dropItem.AddComponent <PickUpItem>();
        dropItem.GetComponent <PickUpItem> ().item = item;

        dropItem.AddComponent <ItemRef> ();
        dropItem.GetComponent <ItemRef> ().item = item;
//		dropItem.GetComponent<PickUpItem>().item = selectedItem.GetComponent<ItemOnObject>().item;

        /* Put the item to this position */
        if (fixedPos == Vector3.zero)
        {
            dropItem.transform.localPosition = new Vector3(_player.transform.localPosition.x, _player.transform.localPosition.y + offSetY, _player.transform.localPosition.z + 1.0f);
        }
        else
        {
            dropItem.transform.localPosition = fixedPos;
        }

        Inventory inv = GetComponent <Inventory> ();

        removeItem(selectedItem);
        inv.OnUpdateItemList();

        // SceneManager
        if (sceneManager.GameSceneIsPreview())
        {
            sceneManager.addToGearList(dropItem);
        }
    }