void RepopulateItems() { foreach (GameObject itemScreen in itemScreens) { GameObject.Destroy(itemScreen); } itemScreens.Clear(); storedFood.Clear(); storedFood = storageManager.GetStoredItems(Item.Category.FOOD); foreach (Item_And_Quantity storedItem in storedFood) { if (storedItem.quantity > 0) { GameObject newItemScreen = GameObject.Instantiate(itemTemplate); newItemScreen.transform.SetParent(itemPanelParent, false); itemScreens.Add(newItemScreen); Screen_Item_Manager itemScreen = newItemScreen.GetComponent <Screen_Item_Manager>(); itemScreen.nameText.text = storedItem.item.name; itemScreen.quantityText.text = storedItem.quantity.ToString(); itemScreen.image.sprite = storedItem.item.storageSprite; } } }
private void Update() { List <Item_And_Quantity> weaponItems = new List <Item_And_Quantity>(); weaponItems = storageManager.GetStoredItems(Item.Category.WEAPONS, Item.Rarity.COMMON); weaponItems.AddRange(storageManager.GetStoredItems(Item.Category.WEAPONS, Item.Rarity.UNCOMMON)); weaponItems.AddRange(storageManager.GetStoredItems(Item.Category.WEAPONS, Item.Rarity.RARE)); foreach (Item_And_Quantity weaponItem in weaponItems) { if (weaponItem.quantity > 0) { if (weapons.ContainsKey(weaponItem.item.name)) { weapons[weaponItem.item.name].itemAndQuantity = weaponItem; } else { weapons.Add(weaponItem.item.name, new Equipped_Weapon(weaponItem)); } } } }
void RepopulateItems() { foreach (GameObject itemScreen in itemScreens) { GameObject.Destroy(itemScreen); } itemScreens.Clear(); storedItemsOfCategoryAndRarity.Clear(); storedItemsOfCategoryAndRarity = storageManager.GetStoredItems(currentCategory, currentRarity); foreach (Item_And_Quantity storedItem in storedItemsOfCategoryAndRarity) { if (storedItem.item.requiredMaterialsToCraft != null && storedItem.item.requiredMaterialsToCraft.requiredItems != null && storedItem.item.requiredMaterialsToCraft.requiredItems.Count > 0) { GameObject newItemScreen = GameObject.Instantiate(itemTemplate); newItemScreen.transform.SetParent(itemPanelParent, false); Button button = newItemScreen.AddComponent <Button>(); button.onClick.AddListener(() => OnClickCraftableItem(storedItem.item)); itemScreens.Add(newItemScreen); Screen_Item_Manager itemScreen = newItemScreen.GetComponent <Screen_Item_Manager>(); itemScreen.nameText.text = storedItem.item.name; itemScreen.quantityText.text = storedItem.quantity.ToString(); itemScreen.image.sprite = storedItem.item.storageSprite; } else { GameObject newItemScreen = GameObject.Instantiate(itemTemplate); newItemScreen.transform.SetParent(itemPanelParent, false); Button button = newItemScreen.AddComponent <Button>(); button.onClick.AddListener(() => OnClickScavengableOnlyItem(storedItem.item)); itemScreens.Add(newItemScreen); Screen_Item_Manager itemScreen = newItemScreen.GetComponent <Screen_Item_Manager>(); itemScreen.nameText.text = storedItem.item.name; itemScreen.quantityText.text = storedItem.quantity.ToString(); itemScreen.image.sprite = storedItem.item.storageSprite; } } }