Exemple #1
0
 // Method runs if the item is clicked
 public void OnPointerClick(PointerEventData eventData)
 {
     click.Play();
     if (this.item != null)                                  // If the player clicks on an actual item:
     {
         if ((item.id > 4 && slot >= 15) || (inHub && item.id > 4 && (item.id % 2 == 0)))
         {
             if (selectedItem.item != null)                          // If there was already a selected item, clone it and replace it with the item clicked on
             {
                 Item clone = new Item(selectedItem.item);           // Puts the cloned item in the place of where the old item used to be
                 if (this.slot >= 18)
                 {
                     if ((slot - 18) == selectedItem.item.category)
                     {
                         selectedItem.UpdateItem(this.item);
                         clone.category = slot - 18;
                         UpdateItem(clone);
                         equipped.EquipItem(clone, slot);
                     }
                 }
                 else
                 {
                     selectedItem.UpdateItem(this.item);
                     UpdateItem(clone);
                     equipped.EquipItem(clone, slot);
                 }
             }
             else
             {
                 if (this.slot >= 18)
                 {
                     equipped.EquipItem(null, slot);
                 }
                 selectedItem.UpdateItem(this.item);             // If there wasn't a selected item, just select this item and replace it with nothing
                 UpdateItem(null);
             }
         }
     }
     else if (selectedItem.item != null)                     // If there was no item in the slot, drop the selected item in said place
     {
         if (slot >= 18)
         {
             if ((slot - 18) == selectedItem.item.category)
             {
                 UpdateItem(selectedItem.item);
                 equipped.EquipItem(selectedItem.item, slot);
                 selectedItem.UpdateItem(null);
             }
         }
         else if ((slot >= 15 && slot <= 17) || (inHub))
         {
             int tempSlot = selectedItem.slot;
             UpdateItem(selectedItem.item);
             //selectedItem.SetSlot(tempSlot);
             selectedItem.UpdateItem(null);
         }
     }
 }
Exemple #2
0
 public void backToHub()
 {
     this.gameObject.transform.position = new Vector3(287.97f, -2.93f, 0f);
     inHub = true;
     inventoryUI.openHub();
     for (int i = 18; i < 21; i++)
     {
         equipped.EquipItem(null, i);
     }
 }