public void handleGameUpdate(NetworkMessage updateMsg) { GameUpdate msg = Deserialize <GameUpdate> (updateMsg.reader.ReadBytesAndSize()); clientRenderer.movePlayer(msg.blueCoords, msg.redCoords); RealtimeTCPController.gotNewBoard(colorToTeam(msg.myColor), formatBoard(msg)); }
public void sendBoardUpdate(Vector3 p1, Vector3 p2) { int[] pos1 = new int[] { (int)p1.x, (int)p1.z }; int[] pos2 = new int[] { (int)p2.x, (int)p2.z }; GameUpdate update = new GameUpdate(updateCounter++, pos1, pos2); broadcastUpdate(update); }
private void broadcastUpdate(GameUpdate update) { foreach (ConnectedPlayer p in players) { update.myColor = p.color; try{ protocol.sendBoard(gameMaster.getMatchingPlayer(p.color).client.peerID, update); }catch { Debug.LogError("Error Sending broadcast"); } } }
public void sendBoard(int targetID, GameUpdate board) { sendMsg(board, targetID, (short)MsgType.gameUpdate); }
private string formatBoard(GameUpdate update) { int[] p1 = (update.myColor == PlayerColor.Green) ? update.blueCoords : update.redCoords; int[] p2 = (update.myColor == PlayerColor.Green) ? update.redCoords : update.blueCoords; return(string.Format("P1: {0}, {1} P2: {2}, {3}", p1 [0], p1 [1], p2 [0], p2 [1])); }