void mainMenuEntry_Selected(object sender, PlayerIndexEventArgs e)
        {
            const string message = "Are you sure you want to quit this game?";

            var confirmQuitMessageBox = new MessageBoxScreen(message);

            confirmQuitMessageBox.Accepted += confirmQuitMessageBox_Accepted;

            ScreenManager.AddScreen(confirmQuitMessageBox, ControllingPlayer);
        }
        protected override void OnCancel(PlayerIndex playerIndex)
        {
            const string message = "Are you sure you want to exit?";

            var confirmExitMessageBox = new MessageBoxScreen(message);

            confirmExitMessageBox.Accepted += confirmExitMessageBox_Accepted;

            ScreenManager.AddScreen(confirmExitMessageBox, playerIndex);
        }
Esempio n. 3
0
        public override void Update(GameTime gameTime, bool otherScreenHasFocus, bool coveredByOtherScreen)
        {

            var names = new Dictionary<long, string>();
            SendNameToServer();

            NetIncomingMessage msg;
            while ((msg = Client.ReadMessage()) != null)
            {

                switch (msg.MessageType)
                {
                    case NetIncomingMessageType.DiscoveryResponse:
                        //just connect to first server discovered
                        //is the server full
                        var canConnect = msg.ReadBoolean();
                        if (canConnect)
                        {
                            Client.Connect(msg.SenderEndpoint);

                        }
                        else
                        {
                            var confirmExitMessageBox = new MessageBoxScreen("Lobby is full.");
                            ScreenManager.AddScreen(confirmExitMessageBox, PlayerIndex.One);
                            confirmExitMessageBox.Accepted += confirmExitMessageBox_Accepted;
                            confirmExitMessageBox.Cancelled += confirmExitMessageBox_Cancelled;
                            Client.Disconnect("full server");
                        }
                        break;
                    case NetIncomingMessageType.Data:
                        var who = msg.ReadInt64();
                        var p2 = msg.ReadString();

                        names[who] = p2;
                        //_names[who] = p2;
                        _names = names;
                        break;
                    case NetIncomingMessageType.WarningMessage:

                        break;

                }
            }

            var i = 0;

            ClearMenuEntries();

            play.Disabled = _names.Count < 2;

            foreach (var p in _names)
            {
                _menuEntryArray[i].Text = p.Value.ToString();
                i++;
            }


            base.Update(gameTime, otherScreenHasFocus, coveredByOtherScreen);
        }