/* * INVENTORY ACTIONS */ public void SetInventory(Responsible responsible) { foreach (Transform child in inventoryParent.transform) { Destroy(child.gameObject); } Dictionary <string, int> inventoryItems = new Dictionary <string, int>(); foreach (var item in responsible.Inventory.Items) { var itemName = item.GetComponent <Interactable.Base.Interactable>().GetGroupName(); if (inventoryItems.ContainsKey(itemName)) { inventoryItems[itemName]++; } else { inventoryItems.Add(itemName, 1); } } var i = 0; foreach (var item in inventoryItems) { var newItem = Instantiate(inventoryItemPrefab, Vector3.zero, Quaternion.identity, inventoryParent.transform); newItem.GetComponent <RectTransform>().anchoredPosition = new Vector3(0f, -i * inventoryItemPrefab.GetComponent <RectTransform>().rect.height, 0f); Equipable equipable = responsible.Inventory.Find(item.Key).GetComponent <Equipable>(); if (equipable && equipable.equipped) { newItem.GetComponent <InventoryItemInfo>().SetItemInfo("(Equipped) " + item.Key, responsible.Inventory.FindCount(item.Key)); } else { newItem.GetComponent <InventoryItemInfo>().SetItemInfo(item.Key, responsible.Inventory.FindCount(item.Key)); } newItem.GetComponent <InventoryItemInfo>().SetActionButton(delegate { UIManager.Instance.SetInteractionPanel(responsible, responsible.Inventory.Find(item.Key).GetComponent <Interactable.Base.Interactable>(), new object[] { responsible.GetComponent <Responsible>() }, Input.mousePosition); }); i++; } }
public IEnumerator Talk(Responsible responsible) { yield return(StartCoroutine(responsible.Walk(interactionPoint.transform.position))); responsible.GetComponent <Responsible>().FinishJob(); }