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); }
private GameObject InstantiateReceipt(AItemBase item) { var prefab = Instantiate(ReceiptPrefab); prefab.GetComponent <ReceiptUI> ().ReceiptId = item.ItemID; _uiitems.Add(prefab.GetComponent <ReceiptUI> ()); return(prefab); }
private GameObject InstantiateGeneric(AItemBase item) { var prefab = Instantiate(GenericPrefab); prefab.GetComponent <GenericUI> ().GenericItemID = item.ItemID; _uiitems.Add(prefab.GetComponent <GenericUI> ()); return(prefab); }
private GameObject InstantiateConsumable(AItemBase item) { var prefab = Instantiate(ConsumablePrefab); prefab.GetComponent <ConsumableUI> ().SetItem((AConsumableBase)item); _uiitems.Add(prefab.GetComponent <ConsumableUI> ()); return(prefab); }
public void Reset() { _currentItem = null; var items = Inventrory.GetInventoryItems(); foreach (var item in items) { item.ToggleOutline(false); } }
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; } } }
public void InitWithItem(AItemBase item) { _item = item; _image.sprite = InventoryImagesLoader.GetImageForItem(item.EItemType, item.ItemID); }