public void OnLongClicked() { Item myItem; myItem = Myitem_Database.FindItemByID(WhichSlot); Tooltip.Activate(myItem); }
public void AddItem(int id) { Item itemToAdd = database.FindItemByID(id); if (itemToAdd == null) { Debug.Log("Blank Space"); return; } if (itemToAdd.Stackable && CheckIfItemIsInInventory(itemToAdd)) { for (int i = 0; i < items.Count; i++) { if (items [i].ID == id) { ItemData data = slots [i].transform.GetChild(0).GetComponent <ItemData> (); data.amount++; data.transform.GetChild(0).GetComponent <Text> ().text = data.amount.ToString(); break; } } } else { for (int i = 0; i < items.Count; i++) { if (items [i].ID == -1) { items [i] = itemToAdd; GameObject itemObj = Instantiate(inventoryItem); itemObj.GetComponent <ItemData> ().item = itemToAdd; itemObj.GetComponent <ItemData> ().slot = i; itemObj.GetComponent <ItemData>().amount = 1; itemObj.transform.SetParent(slots [i].transform); itemObj.GetComponent <RectTransform>().anchoredPosition = new Vector2(0, 0); //itemObj.GetComponent<Image> ().sprite = itemToAdd.Sprite; itemObj.name = itemToAdd.Title; save(); //Logically this souldn't be needed => 베포전 삭제하기 break; } } } }
public void AddItem(int id) { Item itemToAdd = database.FindItemByID(id); if (itemToAdd.Stackable && CheckIfItemIsInInventory(itemToAdd)) //stack가능할 경우 { for (int i = 0; i < items.Count; i++) { if (items [i].ID == id) { StoreItemData data = slots [i].transform.GetChild(0).GetComponent <StoreItemData> (); data.amount++; data.transform.GetChild(0).GetComponent <Text> ().text = data.amount.ToString(); break; } } } else { for (int i = 0; i < items.Count; i++) { if (items [i].ID == -1) { items [i] = itemToAdd; GameObject itemObj = Instantiate(inventoryItem); itemObj.GetComponent <StoreItemData> ().item = itemToAdd; itemObj.GetComponent <StoreItemData> ().slot = i; itemObj.GetComponent <StoreItemData>().amount = 1; itemObj.transform.SetParent(slots [i].transform); itemObj.GetComponent <RectTransform>().anchoredPosition = new Vector2(0, 0); //itemObj.GetComponent<Image> ().sprite = itemToAdd.Sprite; itemObj.name = itemToAdd.Title; itemObj.transform.parent.GetChild(0).SetAsLastSibling(); save(); break; } } } }