コード例 #1
0
 private void BoucleAttente()
 {
     bool debut = false;
     string reponse = "";
     if (netStream.CanRead)
     {
         byte[] bytes = new byte[client.ReceiveBufferSize];
         netStream.Read(bytes, 0, (int)client.ReceiveBufferSize);
         reponse = Encoding.UTF8.GetString(bytes);
     }
     if (reponse == "Debut")
     {
         PlancheJeu planche = new PlancheJeu(StringACharlie, client);
         this.Visible = false;
         planche.ShowDialog();
         this.Close();
         debut = true;
     }
 }
コード例 #2
0
 //Fonction qui fait partire la partie 
 private void BTN_Start_Click(object sender, EventArgs e)
 {
     //String des differents bateau avec leur position sur la plage
    // StringACharlie = BattleShip + PatrolBoat + Destroyer + Submarine + AircraftCarrier;
     StringACharlie = "BattleShip:B0-B1-B2-B3-B4/PatrolBoat:E0-E1/Destroyer:C0-C1-C2-C3/Submarine:D0-D1-D2/AircraftCarrier:A0-A1-A2/";
     if (netStream.CanWrite)
     {
         Byte[] sendBytes = Encoding.UTF8.GetBytes(StringACharlie);
         netStream.Write(sendBytes, 0, sendBytes.Length);
     }
     string reponse = "";
     if (netStream.CanRead)
     {
         byte[] bytes = new byte[client.ReceiveBufferSize];
         netStream.Read(bytes, 0, (int)client.ReceiveBufferSize);
         reponse = Encoding.UTF8.GetString(bytes);
     }
     BTN_Start.Enabled = false;
     if (reponse == "Attendre")
     {
         BoucleAttente();
     }
     else
     {
         PlancheJeu planche = new PlancheJeu(StringACharlie, client);
         this.Visible = false;
         planche.ShowDialog();
         this.Close();
     }
 }