Esempio n. 1
0
        private void InstantiateAtRowIndex(int rowIndex, AItemBase item)
        {
            GameObject prefab;

            switch (item.EItemType)
            {
            case EItemType.Consumable:
            {
                prefab = InstantiateConsumable(item);
                break;
            }

            case EItemType.Receipt:
            {
                prefab = InstantiateReceipt(item);
                break;
            }

            default:
            {
                prefab = InstantiateGeneric(item);
            }

            break;
            }

            prefab.transform.SetParent(_rows [rowIndex].transform);
            prefab.transform.localPosition = Vector3.zero;
            prefab.transform.localScale    = Vector3.one;
            _instantiatedObjects.Add(prefab);
        }
Esempio n. 2
0
        private GameObject InstantiateReceipt(AItemBase item)
        {
            var prefab = Instantiate(ReceiptPrefab);

            prefab.GetComponent <ReceiptUI> ().ReceiptId = item.ItemID;
            _uiitems.Add(prefab.GetComponent <ReceiptUI> ());
            return(prefab);
        }
Esempio n. 3
0
        private GameObject InstantiateGeneric(AItemBase item)
        {
            var prefab = Instantiate(GenericPrefab);

            prefab.GetComponent <GenericUI> ().GenericItemID = item.ItemID;
            _uiitems.Add(prefab.GetComponent <GenericUI> ());
            return(prefab);
        }
Esempio n. 4
0
        private GameObject InstantiateConsumable(AItemBase item)
        {
            var prefab = Instantiate(ConsumablePrefab);

            prefab.GetComponent <ConsumableUI> ().SetItem((AConsumableBase)item);
            _uiitems.Add(prefab.GetComponent <ConsumableUI> ());
            return(prefab);
        }
Esempio n. 5
0
        public void Reset()
        {
            _currentItem = null;
            var items = Inventrory.GetInventoryItems();

            foreach (var item in items)
            {
                item.ToggleOutline(false);
            }
        }
Esempio n. 6
0
        public void DisplayReceiptForItem(string itemId)
        {
            var image = Resources.Load <Sprite> (string.Format(kItemDisplaySpritesPath + itemId));

            _currentItem = ItemsData.GetItemById(itemId);

            _displayImage.gameObject.SetActive(true);
            _displayImage.sprite = image;

            _descriptionText.gameObject.SetActive(true);
            _descriptionText.text = ItemIDStorage.GetDescriptionForItem(itemId);

            ItemName.gameObject.SetActive(true);
            ItemName.text = _currentItem.Name;
            DeleteButton.gameObject.SetActive(true);
            DehighlightAllItems();

            var requiredItemsCount = 0;

            switch (_currentItem.EItemType)
            {
            case EItemType.Receipt:
            {
                var receipt = ItemsData.GetReceiptById(itemId);
                _actionButtonImage.sprite = ButtonImages[0];
                ActionButton.onClick.AddListener(delegate { CraftItem(); });
                HighlightItems(receipt);
                for (int i = 0; i < receipt.RequiredItems.Length; i++)
                {
                    if (Inventrory.GetInventoryItems().Any(item => item.ItemID == receipt.RequiredItems [i]))
                    {
                        requiredItemsCount++;
                    }
                }
                ActionButton.gameObject.SetActive(true);
                ActionButton.interactable = receipt.RequiredItems.Length <= requiredItemsCount;
                break;
            }

            case EItemType.Trap:
            {
                _actionButtonImage.sprite = ButtonImages[1];
                ActionButton.gameObject.SetActive(true);
                ActionButton.onClick.AddListener(delegate { SetATrap(); });
                break;
            }

            default:
            {
                ActionButton.gameObject.SetActive(false);
                break;
            }
            }
        }
Esempio n. 7
0
 public void InitWithItem(AItemBase item)
 {
     _item         = item;
     _image.sprite = InventoryImagesLoader.GetImageForItem(item.EItemType, item.ItemID);
 }