示例#1
0
        private GameConsole(Game game, Dungeon dungeon, IEnumerable<ICommandFactory<ConsoleContext<Dungeon>>> thirdPartyFactories) : base(game)
        {
            In = new StreamReader(input = new KeyboardStream());
            var s = new StreamWriter(ouput = new ScreenStream())
            { AutoFlush = true };
            Out = s;
            interpreter = new BaseInterpreter(defaultFactories.Concat(thirdPartyFactories), In, Out, input)
            { ConsoleContext = new ConsoleContext<Dungeon>(defaultFactories.Concat(thirdPartyFactories), dungeon) };
            new Action(async () =>
            {
                await interpreter.Run();
                return;
            })();

            LoadResources();
            game.Components.Add(this);
        }
示例#2
0
        private GameConsole(Game game, Dungeon dungeon, IEnumerable <ICommandFactory <ConsoleContext <Dungeon> > > thirdPartyFactories) : base(game)
        {
            In = new KeyboardStreamReader(input = new KeyboardStream());
            var s = new StreamWriter(output = new ScreenStream())
            {
                AutoFlush = true
            };

            Out         = s;
            interpreter = new BaseInterpreter(defaultFactories.Concat(thirdPartyFactories), In, Out, input)
            {
                ConsoleContext = new ConsoleContext <Dungeon>(defaultFactories.Concat(thirdPartyFactories), dungeon)
            };
            new Action(async() => await interpreter.Run())();

            LoadResources();
            game.Components.Add(this);
        }