void UpdateEquipment() { for (int i = 0; i < _categories[0].transform.Find("list").childCount; i++) { Destroy(_categories[0].transform.Find("list").GetChild(i).gameObject); } for (int i = 0; i < _categories[1].transform.Find("list").childCount; i++) { Destroy(_categories[1].transform.Find("list").GetChild(i).gameObject); } for (int i = 0; i < Enum.GetNames(typeof(EquipSlot)).Length; i++) { Equipable e = _data.GetEquipment((EquipSlot)i); GameObject g = Instantiate(_equipmentItem, i > (int)EquipSlot.LeftHandItem ? _categories[1].transform.Find("list") : _categories[0].transform.Find("list")); if (e == null) { g.transform.Find("name").GetComponent <Text>().text = "Empty (" + ((EquipSlot)i).ToString() + ")"; g.GetComponent <GenericPointerHandler>().Initialize( null, null, null, null, null); } else { g.transform.Find("name").GetComponent <Text>().text = e.NameToString(); g.GetComponent <GenericPointerHandler>().Initialize( () => Tooltip.Open(e.ToTooltip()), () => { _data.Unequip(e.slot); Player.storage.Add(e); Tooltip.Close(); UpdateEquipment(); UpdateStorage(); }, null, null, () => Tooltip.Close()); } } }
void UpdateEquipment(Actor a) { for (int i = 0; i < Enum.GetNames(typeof(EquipSlot)).Length; i++) { EquipSlot slot = (EquipSlot)i; Equipable e = a.data.GetEquipment((EquipSlot)i); if (e == null) { _equipmentItems[(int)slot].transform.Find("header").GetComponent <Text>().text = "Empty (" + slot.ToString() + ")"; _equipmentItems[(int)slot].GetComponent <GenericPointerHandler>().Initialize( null, null, null, null, null); } else { bool isEquipped = a.data.GetEquipment(e.slot) == e; _equipmentItems[(int)e.slot].transform.Find("header").GetComponent <Text>().text = isEquipped ? e.NameToString() : "Empty (" + e.slot.ToString() + ")"; if (isEquipped) { _equipmentItems[(int)e.slot].GetComponent <GenericPointerHandler>().Initialize( () => Tooltip.Open(e.ToTooltip()), null, null, null, () => Tooltip.Close()); } else { _equipmentItems[(int)e.slot].GetComponent <GenericPointerHandler>().Initialize( null, null, null, null, null); } } } }