public static void AddInvoker_Equip_InvSelect(EquipMenuPanel panelScript) { invokers_Equip_InvSelect.Add(panelScript); //if (listener_Battle_InvSelect != null) foreach (UnityAction <int?> listener in listeners_Equip_InvSelect) { panelScript.AddListener_Equip_InvSelect(listener); } }
// Fills the grid of items with the EquipSlots type of weapon or armor void PopulateGrid() { // Empty any pre-existing panel items for (int i = 0; i < gridContent.transform.childCount; i++) { Destroy(gridContent.transform.GetChild(i).gameObject); } // Create a template grid item GameObject newPanel; GameObject prefabPanel = Resources.Load <GameObject>(@"MenuPrefabs\prefabEquipPanel"); // Populate the grid with any item in the Party inventory, of the current slot foreach (InvItem item in partyStash.Contents) { // Only items appropriate to the slot if (item.Slot == slot) { // Create instances of the prefab, with the Content panel as its parent newPanel = GameObject.Instantiate(prefabPanel, gridContent.transform); EquipMenuPanel equipPanel = newPanel.GetComponent <EquipMenuPanel>(); equipPanel.SetIndex(partyStash.IndexOfItem(item.Name), item.FullName, item.Description, item.Sprite, item.Quantity); } } // Find hero's current item, and display it bool itemEquipped = false; foreach (InvItem item in heroStash.Contents) { if (item.Slot == slot) { currentName.text = item.FullName; currentImage.sprite = item.Sprite; itemEquipped = true; break; } } currentObject.SetActive(itemEquipped); // Highlight an item MakeSelection(selection); // selection is null at start }