private ItemListEntry[] BuildMenu(ItemListEntry[] entries) { if (m_Mobile == null || entries == null || entries.Length == 0) { return(EmptyILE); } ArrayList list = new ArrayList(); for (int i = 0; i < entries.Length; i++) { ItemListEntry entry = entries[i]; if (entry is CraftSubMenu) { if (BuildMenu(((CraftSubMenu)entry).SubItems).Length > 0) { list.Add(entry); } } else if (entry is CraftSystemItem) { CraftSystemItem item = (CraftSystemItem)entry; if (CanCraft(item)) { list.Add(entry); } } else { list.Add(entry); } } return((ItemListEntry[])list.ToArray(typeof(ItemListEntry))); }
private void SetupItemInfo() { TotalMoneyText.text = "Money: " + totalMoney.value; ItemListEntry itemEntry = shopList.GetEntry(); if (!itemEntry || string.IsNullOrEmpty(itemEntry.tuple.uuid)) { itemName.text = ""; itemType.text = ""; itemIcon.color = new Color(0, 0, 0, 0); pwrText.text = "Pwr: "; rangeText.text = "Range: "; hitText.text = "Hit: "; critText.text = "Crit: "; reqText.text = "Req: "; return; } InventoryTuple item = itemEntry.tuple; itemName.text = item.entryName; itemType.text = InventoryContainer.GetWeaponTypeName(item.weaponType); itemIcon.sprite = item.icon; itemIcon.color = item.repColor; pwrText.text = "Pwr: " + item.power.ToString(); rangeText.text = "Range: " + item.range.ToString(); hitText.text = "Hit: " + item.hitRate.ToString(); critText.text = "Crit: " + item.critRate.ToString(); reqText.text = "Req: " + item.skillReq.ToString(); }
private void TakeItem() { Debug.Log("Take item"); ItemListEntry item = convoy.GetEntry(); if (!item) { return; } InventoryContainer invCon = charList.GetEntry().invCon; if (!invCon.AddItem(playerData.items[item.index])) { prompt.ShowOkPopup("Inventory is full!"); currentMode = State.MENU; return; } convoy.RemoveEntry(); playerData.items.RemoveAt(item.index); ShowCharInfo(); ShowCharInfoTake(); ShowItemInfo(); }
public override void OnResponse(NetState state, int index) { if (index < 0 || index >= Entries.Length || state.Mobile.Deleted || !state.Mobile.Alive) { m_System.End(); return; } ItemListEntry entry = Entries[index]; if (entry is CraftSubMenu) { m_System.ShowMenu(((CraftSubMenu)entry).SubItems); } else if (entry is CraftSystemItem) { m_System.OnItemSelected((CraftSystemItem)entry); } else if (entry is CraftMenuCallback) { ((CraftMenuCallback)entry).Callback(m_System, state.Mobile); } else { m_System.End(); } }
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); }
public void SelectItem() { ItemListEntry itemEntry = shopList.GetEntry(); if (!itemEntry || !itemEntry.affordable) { return; } if (!promptMode) { promptMode = true; buyPrompt.ShowYesNoPopup((shopList.buyMode) ? "Buy item?" : "Sell item?", true); } else { if (buyPrompt.Click(true) == MyPrompt.Result.OK1) { if (shopList.buyMode) // Buy item { totalMoney.value -= itemEntry.tuple.cost; playerData.items.Add(itemEntry.tuple.StoreData()); } else // Sell item { totalMoney.value += (int)(itemEntry.tuple.cost * sellRatio.value); playerData.items.RemoveAt(itemEntry.index); shopList.RemoveEntry(); } } shopList.UpdateCost(); SetupItemInfo(); DeselectItem(); } }
public static ItemListEntry[] Main() { ItemListEntry[] entries = new ItemListEntry[3]; entries[0] = new ItemListEntry("Animals", 8482); entries[1] = new ItemListEntry("Creatures", 8408); entries[2] = new ItemListEntry("People", 8460); return(entries); }
private static ItemListEntry[] ParseOptions(Selection[] options) { ItemListEntry[] entries = new ItemListEntry[options.Length]; for (int index = 0; index < options.Length; index++) { entries[index] = options[index].ItemListEntry; } return(entries); }
public ItemListEntry[] CreateGroupList() { CraftGroupCol craftGroupCol = CurrentCraftSystem.CraftGroups; List <ItemListEntry> toReturn = new List <ItemListEntry>(); int hue = 0; if (SelectedResourceIndex > 0) { hue = ResourceInfoList[CurrentCraftSystem.CraftSubRes.GetAt(SelectedResourceIndex)].Hue; } if (hue > 1) { --hue; } for (int i = 0; i < craftGroupCol.Count; i++) { int itemID; CraftGroup craftGroup = craftGroupCol.GetAt(i); if (craftGroup.CraftItems.Count >= 1) { itemID = CraftItem.ItemIDOf(craftGroup.CraftItems.GetAt(0).ItemType); } else { itemID = 5360; //Deed ID } if (craftGroup.NameNumber > 0) { ItemListEntry ile = new ItemListEntry(CliLoc.LocToString(craftGroup.NameNumber), itemID, hue); if (!FilterIndex(i)) { toReturn.Add(ile); } localGroupIndexList.Add(ile, i); } else { ItemListEntry ile = new ItemListEntry(craftGroup.NameString, itemID, hue); if (!FilterIndex(i)) { toReturn.Add(ile); } localGroupIndexList.Add(ile, i); } } toReturn.AddRange(AddSpecialGroups()); return(toReturn.ToArray()); }
public ItemListEntry[] AddSpecialGroups() { List <ItemListEntry> specialGroups = new List <ItemListEntry>(); ItemListEntry entryToAdd; // If the system has more than one resource if (CurrentCraftSystem.CraftSubRes.Init && CurrentCraftSystem.CraftSubRes.Count >= 1) { if (CurrentCraftSystem != DefBlacksmithy.CraftSystem) { ItemListEntry[] resources = CreateResList(); int i = 0; if (resources.Length > 1) { i = 1; } entryToAdd = new ItemListEntry("other resources", resources[i].ItemID, resources[i].Hue); specialGroups.Add(entryToAdd); } else { entryToAdd = new ItemListEntry("Colored Armor", 5402); specialGroups.Add(entryToAdd); } } //Repair if (CurrentCraftSystem.Repair) { int itemID = 5091; if (CurrentCraftSystem == DefTailoring.CraftSystem) { itemID = 5091; } entryToAdd = new ItemListEntry("Repair", itemID); specialGroups.Add(entryToAdd); //localGroupIndexList.Add(entryToAdd, localGroupIndexList.Keys.Count); } //Smelt if (CurrentCraftSystem.Resmelt) { entryToAdd = new ItemListEntry("Re-smelt", 4027); specialGroups.Add(entryToAdd); //localGroupIndexList.Add(entryToAdd, localGroupIndexList.Keys.Count); } return(specialGroups.ToArray()); }
private static ItemListEntry[] GetEquip(Mobile m) { ItemListEntry[] entries = new ItemListEntry[m.Items.Count]; for (int i = 0; i < m.Items.Count; ++i) { Item item = m.Items[i]; entries[i] = new ItemListEntry(String.Format("{0}: {1}", item.Layer, item.GetType().Name), item.ItemID, item.Hue); } return(entries); }
static InscribeSystem() { m_MainMenu = new ItemListEntry[8]; for (int c = 0; c < 8; c++) { ItemListEntry[] entry = new ItemListEntry[8]; for (int n = 0; n < 8; n++) { entry[n] = new CSI_Scroll(c, n, c * 8 + n); } m_MainMenu[c] = new CraftSubMenu(TileData.ItemTable[CircleIDOffset + c].Name, CircleIDOffset + c, entry); } }
public void UpdateCost() { if (!buyMode) { return; } for (int i = 0; i < entryList.Size; i++) { ItemListEntry item = entryList.GetEntry(i); item.SetAffordable(item.tuple.cost <= totalMoney.value); } }
//this adds the listing of all item stores protected bool AddListEntryListing() { if (_ListEntry == null || _ListEntry.ItemListEntries.Count == 0) { return(true); } //write the header info in ItemListEntry entry = _ListEntry.ItemListEntries[0]; for (int j = 0; j < entry.Columns.Count; j++) { AddLabel(40 + entry.Columns[j].X, _Y, (_ListEntry.FilterText[j] == null || _ListEntry.FilterText[j] == "" ? 1153 : 78), entry.Columns[j].Header); AddSortFilterControls(40 + entry.Columns[j].X, _Y + 20, j, _ListEntry.FilterText[j]); } _Y += 40; //list off the items that can be displayed for (int i = _ListingStart; i < _ListingEnd && i < _FilteredEntries.Count; i++) { entry = _FilteredEntries[i]; //add withdrawal button - put buttonid offset of 100 to allow for control/sort/filter button id's uninterrupted AddButton(20, _Y + 3, 0x4B9, 0x4B9, 100 + i, GumpButtonType.Reply, 0); //Add the details about this entry for (int j = 0; j < entry.Columns.Count; j++) { if (entry.Columns[j].Width == 0) { if (j < entry.Columns.Count - 1) { entry.Columns[j].Width = entry.Columns[j + 1].X - entry.Columns[j].X - 10; } else { entry.Columns[j].Width = _Width - entry.Columns[j].X - 10; } } AddLabelCropped(40 + entry.Columns[j].X, _Y, entry.Columns[j].Width, 20, (entry.Hue > 1 ? entry.Hue : 1153), entry.Columns[j].Text); } _Y += EntryLineSpacing; } return(true); }
private void GenerateStorageList() { entryList.ResetList(); int listSize = playerData.items.Count; for (int i = 0; i < listSize; i++) { ItemEntry item = playerData.items[i].item; int charges = playerData.items[i].charges; Transform t = Instantiate(entryPrefab, entryListParent); ItemListEntry entry = entryList.CreateEntry(t); InventoryTuple tup = new InventoryTuple(item); tup.UpdateUpgrades(playerData.upgrader); entry.FillDataSimple(i, tup, charges.ToString(), ""); } entryPrefab.gameObject.SetActive(false); ForceCategory(0); }
private void StoreItem() { ItemListEntry item = itemList.GetEntry(); if (item == null || string.IsNullOrEmpty(item.tuple.uuid)) { return; } Debug.Log("Store item"); int index = itemList.GetPosition(); InventoryTuple tuple = characters.GetEntry().invCon.GetTuple(index); playerData.items.Add(tuple.StoreData()); characters.GetEntry().invCon.DropItem(index); GenerateInventoryList(); itemList.ForcePosition(index); ShowItemInfo(); }
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 TakeItem() { ItemListEntry item = convoy.GetEntry(); if (!item) { return; } Debug.Log("Take item"); InventoryContainer invCon = characters.GetEntry().invCon; if (!invCon.AddItem(playerData.items[item.index])) { restockPrompt.ShowOkPopup("Inventory is full!"); promptMode = true; return; } convoy.RemoveEntry(); playerData.items.RemoveAt(item.index); ShowCharInfo(); }
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(); }
private void GenerateShopList() { entryList.ResetList(); int listSize = (buyMode) ? shopList.items.Count : playerData.items.Count; for (int i = 0; i < listSize; i++) { ItemEntry item = (buyMode) ? shopList.items[i] : playerData.items[i].item; if (buyMode && item.researchNeeded && !playerData.upgrader.IsResearched(item.uuid)) { continue; } Transform t = Instantiate(entryPrefab, entryListParent); ItemListEntry entry = entryList.CreateEntry(t); InventoryTuple tup = new InventoryTuple(item); tup.UpdateUpgrades(playerData.upgrader); int charges = tup.maxCharge; entry.FillData(i, tup, charges.ToString(), totalMoney.value, buyMode, sellRatio.value); } entryPrefab.gameObject.SetActive(false); ForceCategory(0); }
public Selection(ItemListEntry itemListEntry, int context) { m_itemListEntry = itemListEntry; m_context = context; }
public static ItemListEntry[] Main(List <Mobile> list, Mobile from) { int count = 0; ItemListEntry[] entries = new ItemListEntry[12]; string direction = ""; Mobile m_From = from; int missing = 0; for (int i = 0; i < list.Count && i < 12; ++i) { count++; Mobile m = list[i]; Mobile m_Target = list[i]; //North /*if (m_Target.Y < m_From.Y && !(m_Target.Y > m_From.Y - 5)) * { * if (m_Target.X > m_From.X - 5 && m_Target.X < m_From.X + 5) * direction = "to the North."; * else if (m_Target.X > m_From.X) * direction = "to the Northeast."; * else if (m_Target.X < m_From.X) * direction = "to the Northwest."; * } * //South * else if (m_Target.Y > m_From.Y && !(m_Target.Y < m_From.Y + 5)) * { * if (m_Target.X > m_From.X - 5 && m_Target.X < m_From.X + 5) * direction = "to the South."; * else if (m_Target.X > m_From.X) * direction = "to the Southeast."; * else if (m_Target.X < m_From.X) * direction = "to the Southwest."; * } * //East * else if (m_Target.X > m_From.X) * { * if (m_Target.Y > m_From.Y - 5 && m_Target.Y < m_From.Y + 5) * direction = "to the East."; * } * //West * else if (m_Target.X < m_From.X) * { * if (m_Target.Y > m_From.Y - 5 && m_Target.Y < m_From.Y + 5) * direction = "to the West."; * } * //We don't know * else * direction = "in some direction.";*/ if (m_From.GetDirectionTo(m_Target) == Direction.North) { direction = "to the North."; } else if (m_From.GetDirectionTo(m_Target) == Direction.South) { direction = "to the South."; } else if (m_From.GetDirectionTo(m_Target) == Direction.East) { direction = "to the East."; } else if (m_From.GetDirectionTo(m_Target) == Direction.West) { direction = "to the West."; } else if (m_From.GetDirectionTo(m_Target) == Direction.Up) { direction = "to the Northwest."; } else if (m_From.GetDirectionTo(m_Target) == Direction.Left) { direction = "to the Southwest."; } else if (m_From.GetDirectionTo(m_Target) == Direction.Right) { direction = "to the Northeast."; } else if (m_From.GetDirectionTo(m_Target) == Direction.Down) { direction = "to the Southeast."; } else { direction = "in some direction."; } entries[i - missing] = new ItemListEntry(String.Format("{0} {1}", m.Name, direction), ShrinkTable.Lookup(m), 0, i); } for (int i = count; i < 12; i++) { missing++;//entries[i] = new ItemListEntry("", -1); } Array.Resize(ref entries, entries.Length - missing); return(entries); }
public ItemListEntry[] CreateItemList() { CraftGroupCol craftGroupCol = CurrentCraftSystem.CraftGroups; CraftGroup craftGroup = craftGroupCol.GetAt(SelectedGroupIndex); CraftItemCol craftItemCol = craftGroup.CraftItems; ItemListEntry[] toReturn = new ItemListEntry[craftItemCol.Count + 1]; toReturn[0] = new ItemListEntry("Previous menu", 4766);//Previous page int hue = 0; if (CurrentCraftSystem.CraftSubRes.Init && CurrentCraftSystem.CraftSubRes.Count >= 1 && SelectedResType != CurrentCraftSystem.CraftSubRes.GetAt(0).ItemType) { hue = ResourceInfoList[CurrentCraftSystem.CraftSubRes.GetAt(SelectedResourceIndex)].Hue; } if (hue > 1) { --hue; } string resourceList = string.Empty; for (int i = 0; i < craftItemCol.Count; ++i) { CraftItem craftItem = craftItemCol.GetAt(i); //Get the item id and resources required for the items int itemID; if (craftItemCol.Count >= 1) { itemID = CraftItem.ItemIDOf(craftItemCol.GetAt(i).ItemType); int amount = CurrentCraftSystem.CraftGroups.GetAt(SelectedGroupIndex).CraftItems.GetAt(i).Resources.GetAt(0).Amount; if (SelectedResType == null) { if (!string.IsNullOrEmpty(CurrentCraftSystem.CraftGroups.GetAt(SelectedGroupIndex).CraftItems.GetAt(i).Resources.GetAt(0).NameString)) { resourceList = string.Format(" [{0} {1}]", resourceList, amount); } else if (CurrentCraftSystem.CraftGroups.GetAt(SelectedGroupIndex).CraftItems.GetAt(i).Resources.GetAt(0).NameNumber > 0) { resourceList = string.Format(" [{0} {1}]", amount, CliLoc.LocToString(CurrentCraftSystem.CraftGroups.GetAt(SelectedGroupIndex).CraftItems.GetAt(i).Resources.GetAt(0).NameNumber)); } } else { resourceList = string.Format(" [{0} {1}]", amount, CraftResources.GetName(CraftResources.GetFromType(SelectedResType))); } } else { itemID = 5360; //Deed ID } //Becomes 0 if we use a string instead if (craftItem.NameNumber > 0) { toReturn[i + 1] = new ItemListEntry(CliLoc.LocToString(craftItem.NameNumber) + resourceList, itemID, hue); } else { toReturn[i + 1] = new ItemListEntry(craftItem.NameString + resourceList, itemID, hue); } } return(toReturn); }