예제 #1
0
        private static void OpenInventory(Unit pc)
        {
            Window invWindow = new Window(pc, "inventory");
            ShowInvWindow(pc, invWindow);

            ConsoleKeyInfo key;
            bool loop = true;
            do
            {
                key = Console.ReadKey(true);
                int letterCode = key.KeyChar;
                int itemPosition;

                if (char.IsLower(key.KeyChar))
                {
                    if (!key.Modifiers.HasFlag(ConsoleModifiers.Control))
                    {
                        itemPosition = letterCode - 97;
                        if (itemPosition < pc.Inventory.IsSlotUsed.Length && pc.Inventory[itemPosition] != null)
                        {
                            ItemActions(pc, pc.Inventory[itemPosition]);
                        }
                    }
                    else
                    {
                        itemPosition = letterCode + 25 - 97;
                        if (itemPosition < pc.Inventory.IsSlotUsed.Length && pc.Inventory[itemPosition] != null)
                        {
                            ItemActions(pc, pc.Inventory[itemPosition]);
                        }
                    }
                }
                else if (char.IsUpper(key.KeyChar))
                {
                    itemPosition = letterCode - 65;
                    if (itemPosition < pc.Equipment.IsSlotUsed.Length && pc.Equipment[itemPosition] != null)
                    {
                        ItemActions(pc, pc.Equipment[itemPosition]);
                    }
                }
                if (key.Key == ConsoleKey.Escape)
                {
                    loop = false;
                    invWindow.CloseWindow();
                }
            } while (loop);
        }
예제 #2
0
        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);
        }