Ejemplo n.º 1
0
        protected override void OnInitialize(object enterInformation)
        {
            base.OnInitialize(enterInformation);

            _panel = new GuiPanel(Game);

            _connectToServerFrame =
                Game.GuiSystem.CreateGuiHierarchyFromXml <GuiElement>("Content/GuiLayouts/NetworkGame_Layout.xml");

            _connectToServerFrame.FindGuiElementById <Button>("ConnectButton").Click += OnConnect;
            _connectToServerFrame.FindGuiElementById <Button>("BackButton").Click    += OnBack;

            _panel.AddElement(_connectToServerFrame);

            _waitDialog          = Game.GuiSystem.CreateGuiHierarchyFromXml <Frame>("Content/GuiLayouts/WaitDialog.xml");
            _waitDialog.IsActive = false;
            _waitDialog.Title    = string.Empty;
            _waitDialog.FindGuiElementById <TextBlock>("MessageText").Text = "Connecting to Server...";
            _panel.AddElement(_waitDialog);

            _errorDialog          = Game.GuiSystem.CreateGuiHierarchyFromXml <Frame>("Content/GuiLayouts/ConfirmationDialog.xml");
            _errorDialog.IsActive = false;
            _errorDialog.Title    = string.Empty;
            _errorDialog.Color    = Color.Red;
            _errorDialog.FindGuiElementById <Button>("ConfirmButton").Click += () =>
            {
                _errorDialog.IsActive          = false;
                _connectToServerFrame.IsActive = true;
            };
            _panel.AddElement(_errorDialog);

            _gameCreationSession = new RemoteGameCreationSession(Game);
        }
Ejemplo n.º 2
0
        private void OnConnect()
        {
            var host = _connectToServerFrame.FindGuiElementById <TextBox>("ServerTextBox").Text;
            var name = _connectToServerFrame.FindGuiElementById <TextBox>("NickNameTextBox").Text;

            _gameCreationSession.ConnectToServer(host, name);
            _connectToServerFrame.IsActive = false;
            _waitDialog.IsActive           = true;
        }
Ejemplo n.º 3
0
        private void SetButtonTransitionTo(GuiElement root, string buttonId, Type targetState)
        {
            var button = root.FindGuiElementById <Button>(buttonId);

            button.Click += () =>
            {
                _stateChangeInformation = StateChangeInformation.StateChange(targetState, typeof(SlideTransition));
            };
        }