Beispiel #1
0
 /// <summary>
 /// Item is dropped into this cell.
 /// </summary>
 /// <param name="data"></param>
 public void OnDrop(PointerEventData data)
 {
     if (DadItem.icon != null)
     {
         DadCell sourceCell = DadItem.sourceCell;
         if (sourceCell != this)
         {
             DadEventDescriptor desc = new DadEventDescriptor();
             desc.sourceCell      = sourceCell;
             desc.destinationCell = this;
             if (SendGroupRequest(desc) == true)                                             // Send group request
             {
                 SendCellRequest(desc);                                                      // Send cell request
             }
             StartCoroutine(NotifyOnDragEnd(desc));                                          // Send notification after drop will be finished
             if (desc.cellPermission == true && desc.groupPermission == true)                // If drop permitted
             {
                 SwapItems(sourceCell, this);                                                // Swap items between cells
             }
         }
         UpdateMyItem();
         UpdateBackgroundState();
         sourceCell.UpdateMyItem();
         sourceCell.UpdateBackgroundState();
     }
 }
Beispiel #2
0
 /// <summary>
 /// Swaps DaD items between cells.
 /// </summary>
 /// <param name="firstDadCell">First DaD cell.</param>
 /// <param name="secondDadCell">Second DaD cell.</param>
 public static void SwapItems(DadCell firstDadCell, DadCell secondDadCell)
 {
     if ((firstDadCell != null) && (secondDadCell != null))
     {
         GameObject firstItem  = firstDadCell.GetItem();                           // Get item from first cell
         GameObject secondItem = secondDadCell.GetItem();                          // Get item from second cell
         // Swap items
         firstDadCell.PlaceItem(secondItem, false);
         secondDadCell.PlaceItem(firstItem, false);
         // Update states
         firstDadCell.UpdateMyItem();
         secondDadCell.UpdateMyItem();
         firstDadCell.UpdateBackgroundState();
         secondDadCell.UpdateBackgroundState();
     }
 }