//public void FillInEmptySlots() //{ // // there should be at least minNumberOfSlots item slots present in UI // // .. Change this to list and get only first-level items, non-recursive // int numberOfItems = 0; // if (transform.root.Find("MiscUI").GetComponentInChildren<EditPartyScreen>(false) != null) // { // foreach (Transform childTransform in GetComponentInParent<HeroPartyUI>().LHeroParty.transform) // { // // verify if this is InventoryItem // if (childTransform.GetComponent<InventoryItem>() != null) // // increment items count // numberOfItems += 1; // } // } // // verify if we are in battle screen mode // else if (transform.root.Find("MiscUI").GetComponentInChildren<BattleScreen>(false) != null) // { // // get all usable items from party leader equipment // foreach (Transform childTransform in GetComponentInParent<HeroPartyUI>().LHeroParty.GetPartyLeader().transform) // { // // get item // InventoryItem inventoryItem = childTransform.GetComponent<InventoryItem>(); // // verify if there is an item // if (inventoryItem != null) // { // // verify if item is in hero eqipment slot // if (inventoryItem.CurrentHeroEquipmentSlot != HeroEquipmentSlots.None) // { // // increment items count // numberOfItems += 1; // } // } // } // } // else if (transform.root.Find("MiscUI").GetComponentInChildren<PartiesInfoPanel>(false) != null) // { // Debug.Log("Parties info panel is active, probably we are on map. Normally inventory should not be active in this case."); // } // else // { // Debug.LogWarning("Unknown active screen"); // } // // get number of empty item slots // int emptySlots = minNumberOfSlots - numberOfItems; // // create an empty slot for each empty slot // for (int i = 0; i < emptySlots; i++) // { // // create slot in items list // AddSlot(); // } //} // on change - check similar function in HeroEquipment class public void SetItemRepresentationInInventoryUI(InventoryItem inventoryItem, bool setCurrentItemEquipmentSlot = false) { // verify if this is InventoryItem if (inventoryItem != null) { // create drag handler and slotTransform InventoryItemDragHandler dragHandler = AddItemDragHandler(AddSlot(inventoryItem, setCurrentItemEquipmentSlot)); // link item to drag handler dragHandler.LInventoryItem = inventoryItem; // set item name in UI dragHandler.GetComponentInChildren <Text>().text = inventoryItem.ItemName; // verify if item has active modifiers if (inventoryItem.IsUsable) { dragHandler.GetComponentInChildren <Text>().text += inventoryItem.GetUsagesInfo(); } } }
// on change - check similar function in PartyInventoryUI class void SetItemRepresentationInEquipmentUI(InventoryItem inventoryItem) { // verify if this is InventoryItem if (inventoryItem != null) { // create drag handler and slotTransform InventoryItemDragHandler dragHandler = Instantiate(inventoryItemDragHandlerTemplate, GetEquipmentSlotByType(inventoryItem.CurrentHeroEquipmentSlot).transform).GetComponent <InventoryItemDragHandler>(); // link item to drag handler dragHandler.LInventoryItem = inventoryItem; // set item name in UI dragHandler.GetComponentInChildren <Text>().text = inventoryItem.ItemName; // verify if item has active modifiers if (inventoryItem.IsUsable) { dragHandler.GetComponentInChildren <Text>().text += inventoryItem.GetUsagesInfo(); } } }