/// <summary> /// Initialize all data to run storage /// </summary> protected virtual void InitializeStorageData() { _inputManager = Object.FindObjectOfType <InventoryInputManagerExtended>(); GameObject parent = transform.parent.gameObject; _storageInventory = parent.GetComponentInChildren <Inventory>(); SetStorageInventoryName(); _storageInventory.ResizeArray(storageColumns * storageRows); }
/// <summary> /// Initialize all vendor data on load /// </summary> protected virtual void InitializeVendor() { if (canRollBackItems) { rollBackButton.SetActive(true); } else { rollBackButton.SetActive(false); } _itemDetails = Object.FindObjectOfType <InventoryDetailsExtended>(); _inputManager = Object.FindObjectOfType <InventoryInputManagerExtended>(); SetVendorInventoryName(); vendorInventory.ResizeArray(vendorColumns * vendorRows); vendorRollBackInventory.ResizeArray(vendorRollBackColumns * vendorRollBackRows); }
/// <summary> /// Fills the various detail fields with the item's metadata /// </summary> /// <returns>The detail fields.</returns> /// <param name="item">Item.</param> /// <param name="initialDelay">Initial delay.</param> protected override IEnumerator FillDetailFields(InventoryItem item, float initialDelay) { yield return(new WaitForSeconds(initialDelay)); if (Title != null) { Title.text = item.ItemName; } if (ShortDescription != null) { ShortDescription.text = item.ShortDescription; } if (Description != null) { Description.text = item.Description; } if (Quantity != null) { Quantity.text = item.Quantity.ToString(); } if (Icon != null) { Icon.sprite = item.Icon; } #region ------------ Vendor UI (If you don't want vendor you can delete this) --------------- Vendor openedVendor = null; //we get all objects with Vendor script Vendor[] vendors = FindObjectsOfType <Vendor>(); //we loop all Vendors to see if any of them is enabled foreach (Vendor vendor in vendors) { //if vendor is enabled if (vendor.enabled == true && vendor.isOpen) { openedVendor = vendor; } } //we check if our vendor is not null if (openedVendor != null && openedVendor.isOpen) { //we are searching for InventoryInputManagerExtended InventoryInputManagerExtended iime = FindObjectOfType <InventoryInputManagerExtended>(); //and if it's not null if (iime != null) { //we get currently selected slot and data like inventory, index and item InventorySlot _slot = iime.CurrentlySelectedInventorySlot; Inventory _inventory = _slot.ParentInventoryDisplay.TargetInventory; int _index = _slot.Index; InventoryItem _item = _inventory.Content[_index]; //we loop over all disabled items foreach (InventoryItem disabledItem in disabledItems) { //if item is not null if (_item != null) { //and item selected item is disabled item we update item display and hide vendor UI to prevent sell / buy if (disabledItem.name == _item.name) { openedVendor.UpdateVendorItemDisplay(); vendorUI.SetActive(false); } //if item is not in disabled we can update item display and show vendor UI else { openedVendor.UpdateVendorItemDisplay(); vendorUI.SetActive(true); } } } } } #endregion }