public async Task Process(GamePointer gp, List<PlayerState> players, BufferBlock<UpdatePacket> sendChannel) { players.Add(_player); var squares = gp.Game.GetSquares().Select(x => new SquareDTO(x)).ToArray(); //FIXME: right now the order is important here, lest we lack player color information when rendering flags var json2 = JSON.Serialize<PlayerState[]>(players.ToArray()); var packet2 = new UpdatePacket() { Type = "player", Data = json2 }; var j2 = JSON.Serialize<UpdatePacket>(packet2); await _uc.SendAsync(j2); var json = JSON.Serialize<SquareDTO[]>(squares); var packet = new UpdatePacket() { Type = "square", Data = json }; var j = JSON.Serialize<UpdatePacket>(packet); await _uc.SendAsync(j); }
public async Task Process(GamePointer gamePointer, List<PlayerState> players, BufferBlock<UpdatePacket> sendChannel) { if (_player.Dead) { return; } List<Square> changedSquares = gamePointer.Game.Update(_command, _player); if (changedSquares.Count > 0) { var json = JSON.Serialize<Square[]>(changedSquares.ToArray()); var packet = new UpdatePacket() { Type = "square", Data = json }; await sendChannel.SendAsync(packet); } var player = JSON.Serialize<PlayerState>(_player); var pp = new UpdatePacket() { Type = "player", Data = player }; await sendChannel.SendAsync(pp); }
void Awake() { if (Instance != null) { Debug.LogError("GamePointer singleton Error!"); } Instance = this; }