public void OnButtonClick() { if (itemDto.id > 0 && itemDto != null) { if (buttonText.text == "装备") { for (int i = 0; i < Knapsack._instance.EquipGrids.Count; i++) { if (Knapsack._instance.EquipGrids[i].EquipType == itemDto.inventory.equipType) { Knapsack._instance.EquipGrids[i].SetInfo(itemDto); gridUi.CleraInfo(); break; } } } else { bool isFull = false; for (int i = 0; i < Knapsack._instance.equipinventoryGridUis.Count; i++) { if (Knapsack._instance.equipinventoryGridUis[i].num <= 0) { isFull = true; break; } } if (isFull) { NetIO.Instance.Write(Protocol.Map, SceneManager.GetActiveScene().buildIndex, MapProtocol.UnUseInventory_CREQ, itemDto.id); equipGrid.Clear(); GameData.SetEquips((int)itemDto.inventory.equipType, 0); } else { WarrningManager.warringList.Add(new WarringModel("背包已满!", null, 2)); } } gameObject.SetActive(false); } }
public void OnEndDrag(PointerEventData eventData) { //销毁图标 if (dragedIcon != null) { Destroy(dragedIcon.gameObject); } GameObject go = eventData.pointerEnter; if (go != null) { if (go.tag == TAGS.ItemGrid)//拖到格子上 { InventoryGridUi oldGrid = transform.parent.GetComponent <InventoryGridUi>(); InventoryGridUi newGrid = go.GetComponent <InventoryGridUi>(); transform.SetParent(go.transform, false); newGrid.SetInfo(oldGrid.inventoryItemDto); oldGrid.CleraInfo(); } else if (go.tag == TAGS.Item && go != transform.gameObject)//拖到物品上且不是自己 { InventoryItemDTO _itemDto; InventoryGridUi oldGrid = transform.parent.GetComponent <InventoryGridUi>(); InventoryGridUi newGrid = go.transform.parent.GetComponent <InventoryGridUi>(); _itemDto = oldGrid.inventoryItemDto; oldGrid.SetInfo(newGrid.inventoryItemDto); newGrid.SetInfo(_itemDto); } else if (go.tag == TAGS.Shortcut)//快捷栏 { if (ItemDto.inventory.inventoryType == InventoryType.Drug) { go.GetComponent <Shortcut>().SetInfo(ItemDto); } } } else { } }