Ejemplo n.º 1
0
 public void OnPointerUp(PointerEventData eventData)
 {
     if (item != null)
     {
         if (ItemDatabase.instance.money >= item.itemCost && !soldOut && Inventory.instance.items.Count <= Inventory.instance.SlotCnt)
         {
             /*ItemDatabase.instance.money -= item.itemCost;
              * Inventory.instance.AddItem(item);
              * //soldOut = true;
              * inventoryUI.Buy(slotnum);
              * UpdateSlotUI();*/
             if (item.itemType.ToString().Equals("Enrolment"))
             {
                 for (int i = 0; i < Inventory.instance.items.Count; i++)
                 {
                     if (Inventory.instance.items[i].itemName.ToString().Equals("코인"))
                     {
                         for (int j = 0; j < Inventory.instance.items.Count; j++)
                         {
                             if (Inventory.instance.items[j].itemName.ToString().Equals("종이"))
                             {
                                 for (int a = Inventory.instance.items.Count; a >= 0; a--)
                                 {
                                     if (i == a)
                                     {
                                         Inventory.instance.RemoveItem(i);
                                     }
                                     else if (j == a)
                                     {
                                         Inventory.instance.RemoveItem(j);
                                     }
                                 }
                                 Inventory.instance.AddItem(item);
                                 inventoryUI.Buy(slotnum);
                                 UpdateSlotUI();
                                 break;
                             }
                         }
                         break;
                     }
                 }
             }
             else if (item.itemType.ToString().Equals("Bread"))
             {
                 for (int i = 0; i < Inventory.instance.items.Count; i++)
                 {
                     if (Inventory.instance.items[i].itemType.ToString().Equals("Coin") || Inventory.instance.items[i].itemType.ToString().Equals("FreeCoin"))
                     {
                         Inventory.instance.RemoveItem(i);
                         Inventory.instance.AddItem(item);
                         Inventory.instance.AddItem(item);
                         inventoryUI.Buy(slotnum);
                         UpdateSlotUI();
                         break;
                     }
                 }
             }
             else if (item.itemType.ToString().Equals("Paper"))
             {
                 for (int i = 0; i < Inventory.instance.items.Count; i++)
                 {
                     if (Inventory.instance.items[i].itemType.ToString().Equals("Coin") || Inventory.instance.items[i].itemType.ToString().Equals("FreeCoin"))
                     {
                         Inventory.instance.RemoveItem(i);
                         Inventory.instance.AddItem(item);
                         Inventory.instance.AddItem(item);
                         Inventory.instance.AddItem(item);
                         Inventory.instance.AddItem(item);
                         Inventory.instance.AddItem(item);
                         inventoryUI.Buy(slotnum);
                         UpdateSlotUI();
                         break;
                     }
                 }
             }
             else if (item.itemType.ToString().Equals("Coin"))
             {
                 Inventory.instance.AddItem(item);
                 inventoryUI.Buy(slotnum);
                 soldOut = true;
                 UpdateSlotUI();
             }
             else if (item.itemType.ToString().Equals("Water"))
             {
                 Inventory.instance.AddItem(item);
                 inventoryUI.Buy(slotnum);
                 UpdateSlotUI();
             }
             else if (item.itemType.ToString().Equals("FreePaper"))
             {
                 soldOut = false;
                 UpdateSlotUI();
                 Inventory.instance.AddItem(item);
                 inventoryUI.Buy(slotnum);
                 soldOut = true;
                 UpdateSlotUI();
             }
             else if (item.itemType.ToString().Equals("FreeBread"))
             {
                 soldOut = false;
                 UpdateSlotUI();
                 Inventory.instance.AddItem(item);
                 inventoryUI.Buy(slotnum);
                 soldOut = true;
                 UpdateSlotUI();
             }
             else if (item.itemType.ToString().Equals("FreeCoin"))
             {
                 Inventory.instance.AddItem(item);
                 inventoryUI.Buy(slotnum);
                 soldOut = true;
                 UpdateSlotUI();
             }
         }
     }
 }