public FormPlayVsHuman(Setting settingE) { InitializeComponent(); grid = new int[3, 3]; for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) { grid[i, j] = 0; } } setting = settingE; playModel = new Human(1, -1); isPlayer1 = true ; lbluser2.ForeColor = Color.DimGray; lbluser1.ForeColor = Color.White; }
private void setupNames() { while(true){ if (socketManagement.getConnectionType() == SocketManagement.SERVER) { myTurn = true; playModel = new Human(1, -1); lbluser1.Text = me + " - X"; socketManagement.sendMessage(me); while (true) { String name = socketManagement.getMessage(); name=name.Replace("\0", String.Empty); if(Regex.Matches(name,"[a-zA-Z]").Count>2){ //Then the name arrived. opponent = name; lbluser2.Text = (opponent + " - O"); break; } } break; } else if (socketManagement.getConnectionType() == SocketManagement.CLIENT) { myTurn = false; playModel = new Human(-1, 1); lbluser1.Text = me + " - O"; lblReplay.Visible = false; while (true) { String name = socketManagement.getMessage(); name=name.Replace("\0", String.Empty); if (Regex.Matches(name, "[a-zA-Z]").Count > 2) { //Then the name arrived. opponent = name; lbluser2.Text = name + " - X"; socketManagement.sendMessage(me); break; } } break; } } //lbluser2.Text = opponent; }