public void Add_Item(int _id) { Items_Info add_Item = item_DataBase.Search_For_Item(_id); if (add_Item.stackable) { if (!is_Stackable) { is_Stackable = true; // ----------------- for (int i = 0; i < item.Count; i++) { if (item[i].id == -1) { item[i] = add_Item; GameObject item_Obj = Instantiate(item_Prefab); item_Obj.GetComponent <Item>().item_Ability = add_Item; item_Obj.GetComponent <Item>().slot_Location = i; item_Obj.transform.SetParent(slot[i].transform); item_Obj.transform.localPosition = Vector2.zero; item_Obj.GetComponent <Image>().sprite = add_Item.item_Img; item_Obj.name = add_Item.slug; break; } } } else { for (int i = 0; i < item.Count; i++) { if (item[i].id == 30002) { GameObject potion = slot[i].transform.GetChild(0).gameObject; potion.GetComponent <Item>().amount += 2; potion.transform.GetChild(0).GetComponent <Text>().text = potion.GetComponent <Item>().amount.ToString(); } } } } else { for (int i = 0; i < item.Count; i++) { if (item[i].id == -1) { item[i] = add_Item; GameObject item_Obj = Instantiate(item_Prefab); item_Obj.GetComponent <Item>().item_Ability = add_Item; item_Obj.GetComponent <Item>().slot_Location = i; item_Obj.transform.SetParent(slot[i].transform); item_Obj.transform.localPosition = Vector2.zero; item_Obj.GetComponent <Image>().sprite = add_Item.item_Img; item_Obj.name = add_Item.slug; break; } } } }
public static bool AddItem(Items_Info itemInfo) { if (itemInfos.Count < 3) { itemInfos.Add(itemInfo); //Debug.Log("DataTunnel의 아이템 개수 : " + itemInfos.Count); return(true); } //Debug.Log("DataTunnel의 아이템 개수 : " + itemInfos.Count); return(false); }
private void AddItem(int _id, GameObject ShopPanel) { Items_Info add_Item = item_Database.Search_For_Item(_id); GameObject tmp = Instantiate(SlotPrefab, ShopPanel.transform); //tmp.transform.SetParent(ShopPanel.transform); // 안드로이드폰에서 슬롯이 작아지는 문제가 생김 ShopSlot slot = tmp.GetComponent <ShopSlot>(); //Debug.Log(add_Item.name); slot.nameTxt.text = add_Item.name; // 이름 입력 slot.priceTxt.text = "가격 : " + add_Item.price.ToString(); // 가격 입력 slot.infoTxt.text = add_Item.description; // 설명 입력 slot.itemImage.sprite = add_Item.item_Img; // 이미지 입력 slot.id = _id; // ID 입력 }
public void BuyItem(int _id) { itemInfo = item_Database.Search_For_Item(_id); int price = itemInfo.price; Debug.Log("DataTunnel의 아이템 개수 : " + DataTunnel.ItemInfos.Count); if (money < price) { Debug.Log("돈이 부족합니다."); return; } if (DataTunnel.ItemInfos.Count >= 3) { DialoguePanelInvenFull.SetActive(true); return; } this.price = price; DialoguePanelAskIfBuy.SetActive(true); //Debug.Log("Hi"); }