void Check_Can_Craft() { if (first == true) { Create_Need_Item(); first = false; } int check = 0; for (int x = 0; x < itemForCraft_code.Count; x++) { for (int i = 0; i < check_Item.getitemcode_Length(); i++) { if (itemForCraft_code[x] == check_Item.getitemcode(i)) { NeedItem[x].GetComponent <NeedItemSlot>().SetValueHave = check_Item.getitemvalue(i); if (itemForCraft_Value[x] <= check_Item.getitemvalue(i)) { check++; break; } } } This_Button.interactable = (check == itemForCraft_code.Count); } }
public void Remove_Item(string CodeItem, int value) //ใช้งานไอ็เท็ม { int value_for_check = value; for (int x = 0; x < check_item.getitemcode_Length(); x++) { if (CodeItem == check_item.getitemcode(x) && value <= check_item.getitemvalue(x)) { for (int i = Inven_code_string.Length - 1; i >= 0; i--) { if (CodeItem == Inven_code_string[i]) { if (Inven_value_int[i] >= value) { Inven_value_int[i] -= value; value = 0; if (Inven_value_int[i] == 0) { Inven_code_string[i] = check_item.getitemcode(0); } Inven_slot[i].GetComponent <InvenSlot>().LoadItem(); } else if (Inven_value_int[i] < value && Inven_value_int[i] > 0) { value -= Inven_value_int[i]; Inven_value_int[i] = 0; Inven_code_string[i] = check_item.getitemcode(0); Inven_slot[i].GetComponent <InvenSlot>().LoadItem(); } } if (value <= 0) { break; } } Count_Item(CodeItem, -value_for_check, false); } if (value <= 0) { break; } } LinkHotKey(); }