public void SendInitialConnectionAck() { FlatBufferBuilder fbb = new FlatBufferBuilder(1024); var playerInfoOffset = FlatCreator.CreatePlayerInfo(fbb, Id, _playerGo.transform.position.x, _playerGo.transform.position.y, _playerGo.transform.position.z, _playerGo.transform.rotation.x, _playerGo.transform.rotation.y, _playerGo.transform.rotation.z, _playerGo.transform.rotation.w); InitialConnectCommand.StartInitialConnectCommand(fbb); InitialConnectCommand.AddPlayer(fbb, playerInfoOffset); var initialCommandOffset = InitialConnectCommand.EndInitialConnectCommand(fbb); MessageRoot.StartMessageRoot(fbb); MessageRoot.AddDataType(fbb, Data.InitialConnectCommand); MessageRoot.AddData(fbb, initialCommandOffset.Value); var msgRootOffset = MessageRoot.EndMessageRoot(fbb); MessageRoot.FinishMessageRootBuffer(fbb, msgRootOffset); byte[] buf = fbb.SizedByteArray(); _writer.BaseStream.Write(buf, 0, buf.Length); _writer.Flush(); }
public void SendMeetPlayer(string id) { FlatBufferBuilder fbb = new FlatBufferBuilder(1024); var _id = fbb.CreateString(id); PlayerInfo.StartPlayerInfo(fbb); PlayerInfo.AddId(fbb, _id); var playerInfoOffset = PlayerInfo.EndPlayerInfo(fbb); MeetCommand.StartMeetCommand(fbb); MeetCommand.AddOtherPlayer(fbb, playerInfoOffset); var meetCommandOffset = MeetCommand.EndMeetCommand(fbb); MessageRoot.StartMessageRoot(fbb); MessageRoot.AddDataType(fbb, Data.MeetCommand); MessageRoot.AddData(fbb, meetCommandOffset.Value); var msgRootOffset = MessageRoot.EndMessageRoot(fbb); MessageRoot.FinishMessageRootBuffer(fbb, msgRootOffset); byte[] buf = fbb.SizedByteArray(); _writer.BaseStream.Write(buf, 0, buf.Length); _writer.Flush(); }
public void SendMovement(float pX, float pY, float pZ, float rX, float rY, float rZ, float rW) { FlatBufferBuilder fbb = new FlatBufferBuilder(1024); var playerInfoOffset = FlatCreator.CreatePlayerInfo(fbb, Id, pX, pY, pZ, rX, rY, rZ, rW); MovementCommand.StartMovementCommand(fbb); MovementCommand.AddPlayer(fbb, playerInfoOffset); var movementCommandOffset = MovementCommand.EndMovementCommand(fbb); MessageRoot.StartMessageRoot(fbb); MessageRoot.AddDataType(fbb, Data.MovementCommand); MessageRoot.AddData(fbb, movementCommandOffset.Value); var msgRootOffset = MessageRoot.EndMessageRoot(fbb); MessageRoot.FinishMessageRootBuffer(fbb, msgRootOffset); byte[] buf = fbb.SizedByteArray(); _writer.BaseStream.Write(buf, 0, buf.Length); _writer.Flush(); }