void UnpackBox() { List <ItemDB.Item> boxItems = itemDB.GetItemsInBoxPreviously(); int numGoodInBox = 0; for (int i = 0; i < boxItems.Count; i++) { ItemDB.Item boxItem = boxItems[i]; int goodIndex = CheckItemInList(boxItem, itemDB.GetGoodItems()); int badIndex = CheckItemInList(boxItem, itemDB.GetBadItems()); if (goodIndex != -1) { numGoodInBox++; goodItems[goodIndex].SetActive(false); returnedGoodItems[goodIndex].SetActive(true); returnedGoodItems[goodIndex].GetComponentsInChildren <Image>()[0].sprite = boxItem.sprite; } else if (badIndex != -1) { badItems[badIndex].GetComponent <Image>().color = Color.red; gameOver = true; playersWon = false; } else { for (int t = 0; t < trashItems.Count; t++) { GameObject trashItem = trashItems[t]; if (!trashItem.activeSelf) { trashItem.SetActive(true); trashItem.GetComponentsInChildren <Image>()[0].sprite = boxItem.sprite; break; } } } } if (!gameOver && numGoodInBox == 6) { gameOver = true; playersWon = true; } }