예제 #1
0
        public void Reset()
        {
            _currentItem = null;
            var items = Inventrory.GetInventoryItems();

            foreach (var item in items)
            {
                item.ToggleOutline(false);
            }
        }
예제 #2
0
        private void DehighlightAllItems()
        {
            var items = Inventrory.GetInventoryItems();

            var itemsExceptCurrent = items.Where(i => i != null && i.ItemID != _currentItem.ItemID).ToList();

            foreach (var item in itemsExceptCurrent)
            {
                item.ToggleOutline(false);
            }
        }
예제 #3
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;
            }
            }
        }
예제 #4
0
 private void HighlightItems(AReceiptItemBase receipt)
 {
     foreach (var item in Inventrory.GetInventoryItems())
     {
         if (receipt.RequiredItems.Any(i => i == item.ItemID))
         {
             item.ToggleOutline(true);
         }
         else
         {
             item.ToggleOutline(false);
         }
     }
 }