예제 #1
0
    void GiveItem()
    {
        if (playerInventory == null)
        {
            playerInventory = gameManager.Player.GetComponent <PlayerInventory>();
        }

        playerInventory.AddItemsOfType(Item, 1);
    }
예제 #2
0
    void Update()
    {
        for (int i = 1; i < 10; ++i)
        {
            if (i > inventory.Items.Count)
            {
                break;
            }

            if (Input.GetKeyDown("" + i))
            {
                var item = inventory.Items[i - 1].Item;

                inventory.AddItemsOfType(item, -1);

                var throwedObject = Instantiate(item, transform.position, Quaternion.Euler(0, 0, 0));
                throwedObject.GetComponent <Throwable>().Throw(Quaternion.Euler(0, 0, Aim.Rotation) * Vector2.right);
            }
        }
    }