Exemple #1
0
 private void Start()
 {
     _itemDisplay = FindObjectOfType <ItemDisplay>();
     _coinDisplay = FindObjectOfType <CoinDisplay>();
     _itemDisplay.UpdateContainers(_inventoryObject.GetItems().Count);
     _itemDisplay.UpdateSelectedItem(_selectedItem);
     _itemDisplay.UpdateItems(_inventoryObject.GetItems());
     _coinDisplay.UpdateCoins(_inventoryObject.GetCoins());
 }
Exemple #2
0
        private void Update()
        {
            if (Input.GetKeyDown(_switchLeft))
            {
                _selectedItem--;
                if (_selectedItem < 0)
                {
                    _selectedItem = _inventoryObject.GetItems().Count - 1;
                }
                _itemDisplay.UpdateSelectedItem(_selectedItem);
            }
            else if (Input.GetKeyDown(_switchRight))
            {
                _selectedItem++;
                if (_selectedItem > _inventoryObject.GetItems().Count - 1)
                {
                    _selectedItem = 0;
                }
                _itemDisplay.UpdateSelectedItem(_selectedItem);
            }

            // Drop item.
            if (Input.GetKey(_dropKey))
            {
                // Drop the currently held item.
                if (_timeHeld >= _dropTime)
                {
                    DropItem();
                    _timeHeld = 0;
                }
                else
                {
                    _timeHeld += Time.deltaTime;
                }
            }
            else
            {
                _timeHeld = 0;
            }
        }