Esempio n. 1
0
 public static DataChunk fromBytes(byte[] array)
 {
     DataChunk chunk = new DataChunk();
     chunk.pos.X = BitConverter.ToSingle(array, 0);
     chunk.pos.X = BitConverter.ToSingle(array, 4);
     return chunk;
 }
Esempio n. 2
0
 public void Update(GameTime gameTime)
 {
     counter += gameTime.ElapsedGameTime.Milliseconds;
     if (counter > 50)
     {
         if (_socket.Connected)
         {
             DataChunk dataChunk = new DataChunk();
             dataChunk.pos.X = 0.0f;
             dataChunk.pos.Y = (float)gameTime.TotalGameTime.TotalMilliseconds;
             _socket.Send(dataChunk.getBytes());
         }
         counter = 0;
     }
 }
Esempio n. 3
0
 public void Update(GameTime gameTime)
 {
     counter += gameTime.ElapsedGameTime.Milliseconds;
     if (counter > 1000)
     {
         if (_socket.Connected)
         {
             DataChunk chunk = new DataChunk();
             chunk.strData = String.Format("{0} ms have elapsed, connected after {1} attempts", gameTime.TotalGameTime.Milliseconds, attempts);
             IFormatter formatter = new BinaryFormatter();
             byte[] data = System.Text.Encoding.ASCII.GetBytes(chunk.strData);
             _socket.Send(data);
         }
         counter = 0;
     }
 }