public void BeginConnect(Player_Status player) { //show UI player.tryConnectPanel.BringToFront(); // close client to create a new client Client.Close(); Client = new System.Net.Sockets.TcpClient(); IPEndPoint ipEndPoint = new IPEndPoint(IPAddress.Parse(Ipv4), PORT_TRANSFER); int timeout = TIMEOUT; bool tryToconnect; while (true) { if (timeout <= 0) { tryToconnect = false; break; } try { Client.Connect(ipEndPoint); tryToconnect = true; break; } catch { timeout -= 1000; } // show time of timeout player.timeOutlb.Text = (timeout / 1000).ToString() + "s"; Thread.Sleep(1000); } if (tryToconnect == true) { SendIndexOfUser(); player.tryConnectPanel.SendToBack(); player.timeOutlb.Text = (TIMEOUT / 1000).ToString() + "s"; } else { MessageBox.Show("Có lẽ server đã thoát, vui lòng khởi động lại phần mềm "); //Exit Environment.Exit(0); Application.Exit(); } }
public Receive_Manager(Player_Status player, List <enemy> enemy_list) { this.My_player = player; this.Enemy_list_control = enemy_list; score_screen_class = new ScoreScreen_Manager(enemy_list[0].enemy_name_lb.Text);; }
public Current_Player(Player_Status current_player) { encoding = new ASCIIEncoding(); this.Player_panel = current_player; send_manager = new Send_Manager(); }