示例#1
0
        static async Task TaskMain()
        {
            Directory.SetCurrentDirectory(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location));

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

            Interface.Display.Initialize(96, 32);

            ServerConnection server = null;

            UIManager = new UIManager();

            var select = new ServerSelectPrompt("serverselect");
            select.Connect += (sender, e) => {
                UIManager.IsInputBlocked = true;

                server = new ServerConnection("localhost", 14242);
                server.Run();

                UIManager.RemoveChild(select);
                UIManager.CalculateSelectableWidgets();
            };

            UIManager.AddChild(select);
            UIManager.CalculateSelectableWidgets();

            Direction direc = Direction.None;

            while (true) {
                if (server == null) {
                    Draw(null);
                    await Task.Delay(100);
                } else if (Interface.Input.TryReadMovement(out direc)) {
                    server.SendIntent(new MoveIntent(direc));
                } else {
                    await Task.Delay(100);
                }

                await Task.Yield();
            }
        }
示例#2
0
        internal static void Draw(ServerConnection server)
        {
            Interface.Display.Clear();

            if (server != null) {
                // removed Level lock
                var attribs = new DrawAttributes(_flash++);
                var rect = Interface.Display.Rect + server.PlayerPosition - Interface.Display.Center;

                foreach (var vis in server.Visibility) {
                    vis.Draw(rect, Position.Zero, attribs, server.Time);
                }
            }

            // Render user interface
            if (UIManager != null)
                UIManager.Draw();

            Interface.Display.Refresh();
        }