Exemplo n.º 1
0
        private static async Task AsyncMain()
        {
            Directory.SetCurrentDirectory(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location));

            Definitions.LoadFromDirectory("Data", DefinitionsNamespace.Server);

            // TODO: Implement saving / loading levels here.
            var generator = LevelGenerator.Get("test");

            _level = generator.Generate();
            _level.SaveImage("level.png");

            _capacity = 16;

            _clients = new List<ClientConnection>();

            RunListenerLoop();

            while (true)
            {
                if (_clients.Count > 0)
                {
                    _level.Think();
                    await Task.Delay(10);
                }
                else
                {
                    await Task.Delay(100);
                }

                Console.WriteLine(_level.Time);
                Console.CursorTop -= 1;

                await Task.Yield();
            }
        }