private static void ShowInvWindow(Unit unit, Window invWindow) { int letterCount = 0; bool CTRLMod = false; int letterSize = 65; int itemsCount = 0; int itemTypeCode = -1; //unexisting item type Item[] itemsOwned = new Item[unit.Inventory.Count + unit.Equipment.Count]; invWindow.Show(); invWindow.WriteLine("Equipment:", ConsoleColor.Green); for (int i = 0; i < unit.Equipment.IsSlotUsed.Length; i++) { if (unit.Equipment.IsSlotUsed[i] == true) { itemsOwned[itemsCount++] = unit.Equipment[i]; invWindow.Write(string.Format("{0} - {1}: {2}", (char)(unit.Equipment[i].Slot + letterSize), unit.Equipment[i].Slot, unit.Equipment[i].ToString()), ConsoleColor.Yellow); } } letterCount = 0; letterSize = 97; invWindow.WriteLine("Inventory:", ConsoleColor.Green); for (int i = 0; i < unit.Inventory.IsSlotUsed.Length; i++) { if (unit.Inventory.IsSlotUsed[i] == true) { if (itemTypeCode != (int)unit.Inventory[i].ItemAttr.ItemType.BaseType) { itemTypeCode = (int)unit.Inventory[i].ItemAttr.ItemType.BaseType; invWindow.WriteLine(string.Format("{0}:", unit.Inventory[i].ItemAttr.ItemType.BaseType)); } itemsOwned[itemsCount++] = unit.Inventory[i]; if (!CTRLMod) invWindow.Write(string.Format("{0} - {1}", (char)(unit.Inventory[i].InventorySlot + letterSize), unit.Inventory[i].ToString()), ConsoleColor.White); else invWindow.Write(string.Format("^{0} - {1}", (char)(unit.Inventory[i].InventorySlot + letterSize), unit.Inventory[i].ToString()), ConsoleColor.White); if (letterCount > 25 && !CTRLMod) { letterCount = 0; CTRLMod = true; } } } }
public void ShowLogFile(Unit pc) { //create a window Window logWindow = new Window(pc, "log"); logWindow.Show(); using (var sReader = new System.IO.StreamReader(LOG_FILE, ENCODING)) { while (sReader.Peek() != -1) logWindow.Write(sReader.ReadLine()); } ConsoleKeyInfo key; bool loop = true; do { key = Console.ReadKey(true); switch (key.Key) { case ConsoleKey.Escape: loop = false; logWindow.CloseWindow(); break; default: break; } } while (loop); }