Exemplo n.º 1
0
        //When an item is selected from the inventory
        public void SelectItem(string name, Inventory.Type type)
        {
            Item item = Manager.GetInventoryItem(name);

            _currItem = name;
            _currType = type;
            _inventoryUI.SelectItem(item);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Instantiate a button for each item, positioning one
        /// bellow the other and setting scrollview size according
        /// to the items
        /// </summary>
        /// <param name="inventoryScrollView"></param>
        /// <param name="inventoryButton"></param>
        /// <param name="inventory"></param>
        /// <param name="but"></param>
        void DrawInventoryItem(GameObject inventoryScrollView,
                               Button inventoryButton,
                               Inventory inventory,
                               ref Button[] but)
        {
            RectTransform Content;

            inventoryScrollView.SetActive(true);
            Inventory.Type buttonType = inventory.InvType;
            Content = inventoryScrollView.GetComponent <ScrollRect> ().content;

            inventoryButton.gameObject.SetActive(true);

            Cursor.visible = true;
            Time.timeScale = 0;
            DestroyButtons(but);
            but = new Button[inventory.ItemCount()];
            int i = 0;

            foreach (Item item in inventory.ItemKeys())
            {
                but[i] = Instantiate(inventoryButton) as Button;

                but[i].image.rectTransform.sizeDelta = new Vector2(160, _buttonHeight);
                //position the button bellow the previous
                but[i].GetComponent <RectTransform>().anchoredPosition = new Vector2(0, (-(i + 1) * _buttonHeight));
                but[i].transform.localScale = new Vector3(1, 1, 1);

                but[i].GetComponentInChildren <Text> ().text = item.ItemName;

                if (inventory.Items(item) > 1)
                {
                    but [i].GetComponentInChildren <Text> ().text += "(" + inventory.Items(item) + ")";
                }

                but[i].transform.SetParent(inventoryButton.transform.parent, false);
                but[i].enabled = true;

                ItemButton itemButton = but [i].gameObject.GetComponent <ItemButton> ();

                itemButton.Player        = this.gameObject.GetComponent <Player>();
                itemButton.Item          = item;
                itemButton.InventoryType = buttonType;

                i++;
            }

            Content.GetComponent <RectTransform>().sizeDelta = new
                                                               Vector2(0, (inventory.ItemCount() + 1) * _buttonHeight);

            inventoryButton.gameObject.SetActive(false);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Update the item's description
        /// </summary>
        /// <param name="item"></param>
        public void SelectItem(Item item, Inventory.Type type)
        {
            _itemNameText.text    = item.ItemName;
            _descriptionText.text = item.Description;

            _descriptionText.text += "\n\n" + "Weigth: " + item.Weight;

            float price = item.Price;

            if (_player.Trading && type != Inventory.Type.Store)
            {
                if (price > 1)
                {
                    price = price * _player.TradeAdjustment;
                }
            }

            _descriptionText.text += "   Price: " + price;
        }
Exemplo n.º 4
0
 //When an item is selected from the inventory
 public void SelectItem(Item item, Inventory.Type type)
 {
     _currItem = item;
     _invType  = type;
     _inventoryUI.SelectItem(item, _invType);
 }