Ejemplo n.º 1
0
    //Mostly called from Raycaster after interact button clicked
    public void AddItem(ShopItem _item, InteractableObj _script)
    {
        GameObject newObj = GameObject.Instantiate(itemPrefab, _inventoryGrid.transform);

        StartCoroutine(WaitForHold(newObj));
        _currentInv.Add(new InventoryItem(newObj, _item, _script.GetGameObj()));
        InventoryItemDisplay objDisplay = newObj.GetComponent <InventoryItemDisplay>();

        objDisplay._master = this;
        objDisplay._data   = _item;
        objDisplay.SetDisplay(_script);
    }
Ejemplo n.º 2
0
    //Special function for creating game items from prefabs that bought from shop
    private void AddFromShop(ShopItem _item)
    {
        GameObject      newObj   = GameObject.Instantiate(itemPrefab, _inventoryGrid.transform);
        GameObject      _newItem = GameObject.Instantiate(_item.itemPrefab, RayCaster.instance.itemGuide.transform);
        LiftableObjects _script  = _newItem.GetComponent <LiftableObjects>();

        _script.GetObjScripts();
        _script.itemRigid.useGravity        = false;
        _script.itemRigid.isKinematic       = true;
        _newItem.transform.localPosition    = _script.handPosition;
        _newItem.transform.localEulerAngles = _script.handRotation;
        _newItem.transform.localScale       = _item.handScale;
        _currentInv.Add(new InventoryItem(newObj, _item, _newItem));
        InventoryItemDisplay objDisplay = newObj.GetComponent <InventoryItemDisplay>();

        objDisplay._master = this;
        objDisplay._data   = _item;
        objDisplay.SetDisplay(_script);
        _newItem.SetActive(false);
    }