private void OptionDrop() { Menu menu = new Menu() { Prompt = "Select an Item to Drop" }; foreach (var item in DroppableItems) { (var optionColor, var itemTag) = ItemHelper.GetInventoryTag(item, false); menu.Add(itemTag, delegate { GameState.ActiveUnit.Inventory.Remove(item); GameState.ActiveUnit.Area.Inventory.Add(item); if (GameState.ActiveUnit.Weapon == item) { GameState.ActiveUnit.Weapon = null; } }, null, optionColor); } menu.Validate(); menu.Show(); menu.Poll(); }
public override void OnShowHeader() { Console.ForegroundColor = ConsoleColor.Yellow; Console.WriteLine("Inventory:"); Console.ForegroundColor = ConsoleColor.Gray; int column = 0; int columnsPerRow = 5; foreach (var item in GameState.ActiveUnit.Inventory) { (ConsoleColor color, string text) = ItemHelper.GetInventoryTag(item, item == GameState.ActiveUnit.Weapon); Console.ForegroundColor = color; Console.Write($"{text, 25} "); Console.ForegroundColor = ConsoleColor.Gray; column += 1; if (column == columnsPerRow) { column = 0; Console.WriteLine(); } } Console.WriteLine(); }
private void OptionLoot() { Menu menu = new Menu() { Prompt = "Select an Item to Loot" }; foreach (var itemInfo in LootableItems) { string optionText = string.Empty; (var optionColor, var itemTag) = ItemHelper.GetInventoryTag(itemInfo.Item, false); // Check if the item was found on a corpse. if (itemInfo.Corpse != null) { optionText = $"{itemTag} on corpse of {itemInfo.Corpse.Name}."; } else { optionText = $"Nearby {itemTag}"; } menu.Add(optionText, delegate { GameState.ActiveUnit.Inventory.Add(itemInfo.Item); }, null, optionColor); } menu.Validate(); menu.Show(); menu.Poll(); }
private void OptionEquip() { Menu menu = new Menu() { Prompt = "Select a Weapon to Equip" }; foreach (var weapon in EquipableWeapons) { (var optionColor, var itemTag) = ItemHelper.GetInventoryTag(weapon, false); menu.Add(itemTag, delegate { GameState.ActiveUnit.Weapon = weapon; }, null, optionColor); } menu.Validate(); menu.Show(); menu.Poll(); }