Exemple #1
0
 public void EquipButtonClick(int ItemIndex)
 {
     AllItemData[ItemIndex].ItemCount -= 1;
     BagItem.ItemTypes itemType = AllItemData[ItemIndex].ItemType;
     if (AllItemData[ItemIndex].ItemCount == 0)
     {
         AllItemData.RemoveAt(ItemIndex);
         InformationPanel.ClearInformationPanel();
     }
     RefreshBagContent(itemType);
     Debug.Log(AllItemData[ItemIndex].ItemName + "被装备");
 }
Exemple #2
0
 public void ConsumableButtonClick(int ItemIndex, int num)
 {
     AllItemData[ItemIndex].ItemCount -= num;
     BagItem.ItemTypes itemType = AllItemData[ItemIndex].ItemType;
     if (AllItemData[ItemIndex].ItemCount == 0)
     {
         AllItemData.RemoveAt(ItemIndex);
         InformationPanel.ClearInformationPanel();
     }
     RefreshBagContent(itemType);
     Debug.Log(AllItemData[ItemIndex].ItemName + "被使用");
 }
Exemple #3
0
    public void RefreshBagContent(BagItem.ItemTypes ContentType)
    {
        int index = 0;

        for (int j = 0; j < AllItemData.Count; j++)
        {
            if (AllItemData[j].ItemType == ContentType)
            {
                GameObject go;
                if (index < AllItemObject.Count)
                {
                    go = AllItemObject[index];
                }
                else
                {
                    go = GameObject.Instantiate(this.TempItem.gameObject, this.TempScrollRect.content);
                    AllItemObject.Add(go);
                }

                BagSetItem bagSetItem = go.GetComponent <BagSetItem>();
                Button     ItemButton = bagSetItem.ItemButton;
                ItemButton.onClick.RemoveAllListeners();
                int ItemIndex = j;
                ItemButton.onClick.AddListener(() => this.SetInformationPanel(ItemIndex));
                bagSetItem.SetItem(AllItemData[j]);
                index++;
            }
            if (index < AllItemObject.Count)
            {
                for (int i = index; i < AllItemObject.Count; i++)
                {
                    AllItemObject[i].SetActive(false);
                }
            }
        }
    }