void Transact(PointerEventData eventData) { StopPickUpTimer(); if (m_isPickedUp) { SlotGroup targetSG = null; bool swapped = false; bool added = false; Slottable swappedSlottable = null; if (m_slottableUnderCursor != null) // on some slottable { if (m_slottableUnderCursor != this) // the sb is not the orig { m_slottableUnderCursor.OnNonEventDrop(eventData); targetSG = m_SGUnderCursor; if (targetSG != null && targetSG != m_OrigSG) //it's in some other SG { if (this.m_Item.isStackable) { // if(targetSG.GetSlotIndex(this.m_Item.itemId) != -1){ if (m_slottableUnderCursor.m_Item.itemId == this.m_Item.itemId) { /* this is stackable and SBUC is same item */ if (m_OrigSG.isSubtractable) { Add(targetSG); added = true; } } else { /* this is stackable but SBUC has different item */ Swap(m_slottableUnderCursor); swapped = true; swappedSlottable = m_slottableUnderCursor; } } else { /* this is not stackable */ if (m_slottableUnderCursor.m_itemInstance != this.m_itemInstance) { Swap(m_slottableUnderCursor); swapped = true; swappedSlottable = m_slottableUnderCursor; } else { if (m_OrigSG.isSubtractable) { Add(targetSG); added = true; } } } } else //targetSG == null || targetSG == m_OrigSG { StartCoroutine(Revert(eventData)); return; } } else //m_slottableUnderCursor == this { OnNonEventDrop(eventData); m_isTouchedInside = false; m_isTouchedOutside = false; StartCoroutine(WaitAndReset(eventData)); return; } } else //slottableUnderCursor == null { if (m_SGUnderCursor != null) { if (m_SGUnderCursor != m_OrigSG) // in some other SG { targetSG = m_SGUnderCursor; if (m_SGUnderCursor.SlotCount == 1) { if (m_SGUnderCursor[0].slottable != null) { if (m_SGUnderCursor[0].slottable.m_Item.itemId == this.m_Item.itemId && this.m_Item.isStackable) { /* this is stackable and the only Slottable the SG has has the same item */ if (m_OrigSG.isSubtractable) { Add(m_SGUnderCursor); added = true; } } else { /* this is not stackable, nor the only slottable has different item */ Swap(m_SGUnderCursor[0].slottable); swapped = true; swappedSlottable = m_SGUnderCursor[0].slottable; } } else { /* the only slot doesn't have a slottable so fill it */ if (m_OrigSG.isSubtractable) { Add(m_SGUnderCursor); added = true; } } } else //more than one slot { if (m_SGUnderCursor.HasVacancy) { //filled if (m_OrigSG.isSubtractable) { Add(m_SGUnderCursor); added = true; } } else //no vacancy { if (m_SGUnderCursor.isExpandable) { if (m_OrigSG.isSubtractable) { Add(m_SGUnderCursor); added = true; } } else if (m_SGUnderCursor.GetSlotIndex(m_Item.itemId) != -1) //the SG has same item { if (this.m_Item.isStackable) { /* same and stackable */ if (m_OrigSG.isSubtractable) { Add(m_SGUnderCursor); added = true; } } // else{ // /* this is not stackable // */ // StartCoroutine(Revert(eventData)); // return; // } } // else{ // /* no same item in the sg // */ // StartCoroutine(Revert(eventData)); // return; // } } } } else //SGUC is the orig SG, and there's no SBUC { StartCoroutine(Revert(eventData)); return; } } else //there's no SGUC nor SBUC { StartCoroutine(Revert(eventData)); return; } } if (!added && !swapped) { StartCoroutine(Revert(eventData)); } else { targetSG.CleanUpData(); this.m_OrigSG.CleanUpData(); targetSG.SortData(); this.m_OrigSG.SortData(); targetSG.UpdateSlots(eventData); this.m_OrigSG.UpdateSlots(eventData); this.StartCoroutine(this.MoveToSlot(targetSG, targetSG.GetNewSlotRect(this), eventData)); if (swapped) { swappedSlottable.m_draggedIcon = swappedSlottable.CreateAndSetupDraggedIcon(m_canvas, ref swappedSlottable.m_pickedQuantText); swappedSlottable.m_draggedIcon.GetComponent <RectTransform>().anchoredPosition = ConvertRectPosToCanvasPos(swappedSlottable.m_OrigSG.GetSlotRect(swappedSlottable), eventData); swappedSlottable.StartCoroutine(swappedSlottable.MoveToSlot(this.m_OrigSG, this.m_OrigSG.GetNewSlotRect(swappedSlottable), eventData)); } } } else { m_isTouchedInside = false; m_isTouchedOutside = false; StartCoroutine(WaitAndReset(eventData)); } }