Skip to content
Snippets Groups Projects
Commit 270ecb13 authored by HOFFMANN MARTIN's avatar HOFFMANN MARTIN
Browse files

Fin du Tron 2 joueurs

parent 87442ee1
Tags v2.0
No related merge requests found
Showing
with 44 additions and 8 deletions
No preview for this file type
File added
File added
......@@ -14,11 +14,22 @@ namespace TronClient
public byte frequence; // Temps du tour de jeu (en dixieme de s)
public Socket clientSocket;
public IPEndPoint serverEP;
byte[] buffer = new byte[80];
// constructeur : IP/Port du serveur
public Client(String myServerIP, int myServerPort)
{
// TODO : Creation de la socket d'écoute TCP
clientSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
Console.WriteLine("Tentative de connexion...");
serverEP = new IPEndPoint(IPAddress.Parse(myServerIP), myServerPort);
}
......@@ -27,15 +38,20 @@ namespace TronClient
{
System.Console.WriteLine("Init");
// TODO Connexion au serveur
// TODO Connexion au serveur
clientSocket.Bind(new IPEndPoint(IPAddress.Any, 22222));
clientSocket.Connect(serverEP);
// TODO Réception des paramètres
byte[] bufferParam = new byte[4];
clientSocket.Receive(bufferParam, bufferParam.Length, SocketFlags.None);
// TODO Initialisation de la fréquence : frequence = <frequence>
frequence = 1;
frequence = bufferParam[2];
// TODO Initialisation du moteur : myTron = new Tron(byte <taille terrain>, byte <nombre de joueurs>, byte <numéro du joueur>);
myTron = new Tron.Tron(60, 2, 0);
myTron = new Tron.Tron(bufferParam[0], bufferParam[1], bufferParam[3]);
// Retourne le moteur
return myTron;
......@@ -47,8 +63,16 @@ namespace TronClient
System.Console.WriteLine("Routine");
// TODO Envoie de sa direction : myTron.getDirection()
byte[] buffer = new byte[2];
buffer[0] = myTron.getDirection();
buffer[1] = myTron.getMonNum();
clientSocket.Send(buffer, 0, buffer.Length, SocketFlags.None);
// TOSO Reception de toutes les directions : myTron.setDirections(byte[] < toutes les directions>);
byte[] bufferDirection = new byte[myTron.getNJoueurs()];
clientSocket.Receive(bufferDirection, bufferDirection.Length, SocketFlags.None);
myTron.setDirections(bufferDirection);
}
// Appelé à la fin de la partie
......@@ -57,6 +81,7 @@ namespace TronClient
System.Console.WriteLine("Conclusion");
// fermeture socket
clientSocket.Close();
}
......
......@@ -49,7 +49,7 @@
this.textBoxIP.Name = "textBoxIP";
this.textBoxIP.Size = new System.Drawing.Size(123, 20);
this.textBoxIP.TabIndex = 1;
this.textBoxIP.Text = "127.0.0.1";
this.textBoxIP.Text = "192.168.137.63";
//
// textBoxPort
//
......@@ -57,7 +57,7 @@
this.textBoxPort.Name = "textBoxPort";
this.textBoxPort.Size = new System.Drawing.Size(50, 20);
this.textBoxPort.TabIndex = 2;
this.textBoxPort.Text = "8000";
this.textBoxPort.Text = "11111";
//
// FormLobby
//
......
......@@ -112,9 +112,9 @@
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>
\ No newline at end of file
File added
File added
File added
File added
File added
File added
File added
File added
9dec7497afe9838e6bc3791c1e89ce650863851a
D:\Cours\Année2\S32\S32\Tron\TronClient\TronClient\bin\Debug\TronClient.exe
D:\Cours\Année2\S32\S32\Tron\TronClient\TronClient\bin\Debug\TronClient.pdb
D:\Cours\Année2\S32\S32\Tron\TronClient\TronClient\obj\Debug\TronClient.FormLobby.resources
D:\Cours\Année2\S32\S32\Tron\TronClient\TronClient\obj\Debug\TronClient.FormTron.resources
D:\Cours\Année2\S32\S32\Tron\TronClient\TronClient\obj\Debug\TronClient.Properties.Resources.resources
D:\Cours\Année2\S32\S32\Tron\TronClient\TronClient\obj\Debug\TronClient.csproj.GenerateResource.Cache
D:\Cours\Année2\S32\S32\Tron\TronClient\TronClient\obj\Debug\TronClient.csproj.CoreCompileInputs.cache
D:\Cours\Année2\S32\S32\Tron\TronClient\TronClient\obj\Debug\TronClient.exe
D:\Cours\Année2\S32\S32\Tron\TronClient\TronClient\obj\Debug\TronClient.pdb
D:\Cours\Année2\S32\S32\Tron\TronClient\TronClient\obj\Debug\TronClient.csprojResolveAssemblyReference.cache
File added
File added
File added
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment