public byte[] Serialize(Messages m) { MemoryStream stream = new MemoryStream(); BinaryFormatter b = new BinaryFormatter(); b.Serialize(stream, m); return stream.GetBuffer(); }
public void Send(Messages message) { try { MemoryStream stream = new MemoryStream(); BinaryFormatter b = new BinaryFormatter(); stream.Position = 0; b.Serialize(stream, message); socket.Send(stream.GetBuffer()); } catch (Exception e) { BigStaticClass.logger.Log(e.ToString()); } }
void Step(Messages message) { ShootMessage shoot = message as ShootMessage; Gamer first = gamers.First(x => x.client.Id != shoot.Id); Gamer second = gamers.First(x => x.client.Id == shoot.Id); BigStaticClass.logger.Log("Игрок " + second.client.nick + " сделал ход по координатам " + shoot.x.ToString() + " " + shoot.y.ToString()); if (second.turn) { second.turn = first.client.gameField.Shoot(shoot.x, shoot.y); first.turn = !second.turn; if (second.turn && first.client.gameField.IsGameOver()) { GameOver(); } StateOfRoom(); } }