private BagItem MakeBagItem(Item item, int amount) { RectTransform itemSlotRectTransform = Instantiate(itemTemplate, bagContainer); itemSlotRectTransform.gameObject.SetActive(true); BagItem bagItem = itemSlotRectTransform.GetComponent <BagItem>(); bagItem.SetItem(item, amount); return(bagItem); }
private void UpdateUI(bool isChange = false) { if (RoleData.mainRole == null) { return; } max_item = RoleData.mainRole.GetAttr(RoleAttribute.max_item); if (show_pack == ItemType.end) { show_items = RoleData.mainRole.bag_items; } else { show_items = new List <int>(); foreach (int item_id in RoleData.mainRole.bag_items) { if (GameData.instance.item_static_data[GameData.instance.all_item[item_id].static_id].type == show_pack) { show_items.Add(item_id); } } max_item = show_items.Count; } line_count = (int)Mathf.Ceil(max_item * 1f / child_count); // 设置背包 if (!isChange) { scrollView.verticalNormalizedPosition = 1; } bigDataScroll.cellCount = line_count; // 设置装备 for (int i = 0; i < equip_items.Length; i++) { int item_id = RoleData.mainRole.equip_items[i]; ItemData item; if (item_id >= 0) { item = GameData.instance.all_item[item_id]; } else { item = null; } BagItem bagItem = equip_items[i]; bagItem.SetItem(item, RoleData.mainRole, isRound: true, show_count: MessageData.GetMessage(29 + i), clickFunc: bagItem.BtnEquip); } // 设置战斗药 for (int i = 0; i < battle_items.Length; i++) { int item_id = RoleData.mainRole.remedy_items[i]; ItemData item; if (item_id >= 0) { item = GameData.instance.all_item[item_id]; } else { item = null; } BagItem bagItem = battle_items[i]; bagItem.SetItem(item, RoleData.mainRole, show_count: item == null?"":(item.count > 5 ? 5 : item.count).ToString(), clickFunc: bagItem.BtnEquip); } }