Exemple #1
0
 public GameQuestion(JSON_Classes.RoomData rules)
 {
     InitializeComponent();
     roomRules    = rules;
     watch        = new Stopwatch();
     buttons      = new [] { AnswerOneButton, AnswerTwoButton, AnswerThreeButton, AnswerFourButton };
     defaultColor = AnswerOneButton.BackColor; // Save it for later.
     for (int i = 0; i < buttons.Length; i++)
     {
         buttons[i].Click    += AnswerButton_Click;
         buttons[i].BackColor = defaultColor;
     }
 }
Exemple #2
0
        private void CreateLobbyButton_Click(object sender, EventArgs e)
        {
            var form = new LobbyDetailsForm();

            this.Hide();
            form.ShowDialog();
            var request = new JSON_Classes.CreateRoomRequest {
                Name = form.Name, MaxUsers = form.MaxUsers, QuestionCount = form.QuestionCount, TimePerQuestion = form.TimePerQuestion
            };

            byte[] message = GlobalHelpers.CreateMessage("116", request);
            ClientSocket.client.Send(message);
            byte[] response  = new byte[1024];
            int    bytesRead = ClientSocket.client.Receive(response);

            Array.Resize <byte>(ref response, bytesRead);
            if (GlobalHelpers.GetCode(response) == "216")
            {
                var result   = MessagePack.MessagePackSerializer.Deserialize <JSON_Classes.CreateRoomResponse>(GlobalHelpers.GetMsgpack(response));
                var room     = new JSON_Classes.Room();
                var metadata = new JSON_Classes.RoomData();
                metadata.IsActive      = 0;
                metadata.id            = result.Id;
                metadata.name          = request.Name;
                metadata.MaxPlayers    = request.MaxUsers;
                metadata.QuestionCount = request.QuestionCount;
                metadata.AnswerTimeout = request.TimePerQuestion;
                room.Players           = new[] { username };
                room.Metadata          = metadata;
                var gameLobby = new LobbyScreenAdmin(room);
                this.Hide();
                gameLobby.ShowDialog();
                this.Show();
            }
            else
            {
                MessageBox.Show("Error Creating Lobby!");
                this.Close();
            }
        }