示例#1
0
        public GameEngine(string id, GameEngineConfig config, ConsoleOut consoleOut)
        {
            if (string.IsNullOrWhiteSpace(id))
            {
                throw new ArgumentNullException("id");
            }

            if (null == config)
            {
                throw new ArgumentNullException("config");
            }

            if (null == consoleOut)
            {
                throw new ArgumentNullException("consoleOut");
            }

            ID         = id;
            Config     = config;
            ConsoleOut = consoleOut;

            InitAI();

            ExitRequested = false;
        }
示例#2
0
文件: Program.cs 项目: tswaugh/Mzinga
        static void Main(string[] args)
        {
            Console.OutputEncoding = Encoding.UTF8;

            GameEngineConfig config = null != args && args.Length > 0 ? LoadConfig(args[0]) : GameEngineConfig.GetDefaultEngineConfig();

            _engine = new GameEngine(ID, config, PrintLine);
            _engine.ParseCommand("info");

            Console.CancelKeyPress += Console_CancelKeyPress;

            _engine.StartAsyncCommand += (s, e) =>
            {
                _interceptCancel = true;
            };

            _engine.EndAsyncCommand += (s, e) =>
            {
                _interceptCancel = false;
            };

            while (!_engine.ExitRequested)
            {
                string command = Console.ReadLine();
                if (!string.IsNullOrWhiteSpace(command))
                {
                    _engine.ParseCommand(command);
                }
            }
        }
示例#3
0
        public GameEngine(string id, GameEngineConfig config, ConsoleOut consoleOut)
        {
            if (string.IsNullOrWhiteSpace(id))
            {
                throw new ArgumentNullException(nameof(id));
            }

            ID            = id;
            Config        = config ?? throw new ArgumentNullException(nameof(config));
            DefaultConfig = config.GetOptionsClone();
            ConsoleOut    = consoleOut ?? throw new ArgumentNullException(nameof(consoleOut));

            ExitRequested = false;
        }