private void UpdateInventoryList() { for (int i = 0; i < InventoryContainer.INVENTORY_SIZE; i++) { InventoryTuple tuple = characters.GetEntry().invCon.GetTuple(i); if (string.IsNullOrEmpty(tuple.uuid)) { if (currentMode == MenuState.STORE) { Transform t2 = Instantiate(restockPrefab, listParentRestock); ItemListEntry entry2 = itemList.CreateEntry(t2); entry2.FillDataEmpty(i); } continue; } ItemListEntry entry = itemList.GetEntry(i); int charges = 0; float cost = 0; CalculateCharge(tuple, ref cost, ref charges, false); string chargeStr = tuple.currentCharges + " / " + tuple.maxCharge; string costStr = (currentMode == MenuState.RECHARGE) ? Mathf.CeilToInt(cost * charges).ToString() : ""; entry.FillDataSimple(i, tuple, chargeStr, costStr); } itemList.Move(0); }
private void GenerateInventoryList() { inventoryView.SetActive(true); charListView.SetActive(false); storeView.SetActive(true); convoyView.SetActive(false); TotalMoneyText.text = "Money: " + totalMoney.value; if (itemList == null) { itemList = new EntryList <ItemListEntry>(itemListSize); } itemList.ResetList(); for (int i = 0; i < InventoryContainer.INVENTORY_SIZE; i++) { InventoryTuple tuple = charList.GetEntry().invCon.GetTuple(i); if (string.IsNullOrEmpty(tuple.uuid)) { Transform t2 = Instantiate(restockPrefab, listParentRestock); ItemListEntry entry2 = itemList.CreateEntry(t2); entry2.FillDataEmpty(i); continue; } Transform t = Instantiate(restockPrefab, listParentRestock); ItemListEntry entry = itemList.CreateEntry(t); int charges = 0; float cost = 0; CalculateCharge(tuple, ref cost, ref charges, false); string chargeStr = tuple.currentCharges + " / " + tuple.maxCharge; string costStr = Mathf.CeilToInt(cost * charges).ToString(); entry.FillDataSimple(i, tuple, chargeStr, costStr); } restockPrefab.gameObject.SetActive(false); }
private void StoreItem() { Debug.Log("Store item"); if (itemList.GetEntry().tuple == null) { return; } InventoryTuple tuple = charList.GetEntry().invCon.GetTuple(itemList.GetPosition()); playerData.items.Add(tuple.StoreData()); charList.GetEntry().invCon.DropItem(itemList.GetPosition()); charList.GetEntry().invCon.CleanupInventory(); itemList.RemoveEntry(); Transform t2 = Instantiate(restockPrefab, listParentRestock); ItemListEntry entry2 = itemList.CreateEntry(t2); entry2.FillDataEmpty(0); ShowItemInfo(); }
private void GenerateInventoryList() { TotalMoneyText.text = "Money: " + totalMoney.value; characters.GetEntry().invCon.CleanupInventory(); itemList.ResetList(); for (int i = 0; i < InventoryContainer.INVENTORY_SIZE; i++) { InventoryTuple tuple = characters.GetEntry().invCon.GetTuple(i); if (string.IsNullOrEmpty(tuple.uuid)) { if (currentMode == MenuState.STORE) { Transform t2 = Instantiate(restockPrefab, listParentRestock); ItemListEntry entry2 = itemList.CreateEntry(t2); entry2.FillDataEmpty(i); } continue; } Transform t = Instantiate(restockPrefab, listParentRestock); ItemListEntry entry = itemList.CreateEntry(t); int charges = 0; float cost = 0; CalculateCharge(tuple, ref cost, ref charges, false); string chargeStr = tuple.currentCharges.ToString(); if (currentMode == MenuState.RECHARGE) { chargeStr += " / " + tuple.maxCharge; } string costStr = (currentMode == MenuState.RECHARGE) ? Mathf.CeilToInt(cost * charges).ToString() : ""; entry.FillDataSimple(i, tuple, chargeStr, costStr); } restockPrefab.gameObject.SetActive(false); ShowItemInfo(); }