Example #1
0
        public void Run()
        {
            Player.ChangeLocation(new Locations.OfficeBuilding.TheCloset.DarkPlace());
            PrintHeader();
            Console.ForegroundColor = ConsoleColor.DarkGray;
            do
            {
                DrawInventory();

                OutputPane.Draw();

                ExtendedConsole.ClearConsoleLine(49);
                Console.SetCursorPosition(0, 49);
                var str = ReadMyLine(PrintStr, Tabcallback).Trim();

                var match = Player.Verbs.FirstOrDefault(
                    o => o.FirstPart.Permute().Any(x => x.ToString().Equals(str, StringComparison.InvariantCultureIgnoreCase)));

                if (match?.Action != null)
                {
                    if (!CommandHistory.LastOrDefault()?.Equals(str, StringComparison.InvariantCultureIgnoreCase) ?? true)
                    {
                        CommandHistory.Add(str);
                    }

                    if (OutputPane.Entries.Last().Length != 0)
                    {
                        OutputPane.WriteLine();
                    }
                    //OutputPane.Write($"{str}> ".DarkGray());
                    match.Action(str);
                }
                else
                {
                    ExtendedConsole.ClearConsoleLine(48);
                    Console.SetCursorPosition(0, 48);
                    "\rCould not find that command...".Red(true).Write();
                }
                CommandHistoryIndex = 0;
            } while (Player.Verbs.Any());
        }
Example #2
0
        private static void ScrollingPaneDemo()
        {
            var c = new ScrollingPane(10, 5, 40, 20);

            {
                Console.SetCursorPosition(9, 4);
                Console.Write('╔');
                Console.Write(new string('═', 40));
                Console.Write('╗');

                for (int i = 0; i < 20; i++)
                {
                    Console.SetCursorPosition(9, 5 + i);
                    Console.Write('║');
                    Console.SetCursorPosition(50, 5 + i);
                    Console.Write('║');
                }

                Console.SetCursorPosition(9, 25);
                Console.Write('╚');
                Console.Write(new string('═', 40));
                Console.Write('╝');
            }
            Console.CursorVisible = false;
            Console.ReadKey(true);

            Random r     = new Random();
            var    names = Enum.GetNames(typeof(ConsoleColor));

            for (int i = 0; i < 50; i++)
            {
                if (i != 0)
                {
                    c.WriteLine();
                }
                for (int j = 0; j < i + 1; j++)
                {
                    c.Write("Text! ", (ConsoleColor)Enum.Parse(typeof(ConsoleColor), names[r.Next() % (names.Length - 1)]),
                            (ConsoleColor)Enum.Parse(typeof(ConsoleColor), names[r.Next() % (names.Length - 1)]));
                    //c.Write("Text! ");
                    c.Draw();
                    Thread.Sleep(25);
                }
            }

            //c.Draw();

            Console.ReadLine();
        }