private void SendPlayerDisconnectBroadcast(ClientData clientData, int disconnectedClientId) { var packet = Packet.Obtain(); ServerSerializationManager.SerializePlayerDisconnectBroadcast(packet.buffer, disconnectedClientId); packet.buffer.Flush(); clientData.Channel.Send(packet, clientData.ClientIpEndPoint); packet.Free(); }
private void SendPlayerShotBroadcast(ClientData clientData, int shooterId, int shotPlayerId, int health) { var packet = Packet.Obtain(); ServerSerializationManager.SerializePlayerShotBroadcast(packet.buffer, shooterId, shotPlayerId, health); packet.buffer.Flush(); clientData.Channel.Send(packet, clientData.ClientIpEndPoint); packet.Free(); }
private void SendPlayerRespawnBroadcast(ClientData clientData, int shotPlayerId, Vector3 newPosition) { var packet = Packet.Obtain(); ServerSerializationManager.SerializePlayerRespawnBroadcast(packet.buffer, shotPlayerId, newPosition, nextSnapshotSeq); packet.buffer.Flush(); clientData.Channel.Send(packet, clientData.ClientIpEndPoint); packet.Free(); }
private void SendSnapshotToClient(int clientId, ClientData clientData) { var packet = Packet.Obtain(); ServerSerializationManager.ServerWorldSerialize(packet.buffer, nextSnapshotSeq, serverTime, clientId, clients); packet.buffer.Flush(); clientData.Channel.Send(packet, clientData.ClientIpEndPoint); packet.Free(); }
private static void SendPlayerJoined(ClientData clientData, int newUserId, string newClientName, Transform newClientTransform) { var packet = Packet.Obtain(); ServerSerializationManager.SerializePlayerJoined(packet.buffer, newUserId, newClientName, newClientTransform.position, newClientTransform.rotation); packet.buffer.Flush(); clientData.Channel.Send(packet, clientData.ClientIpEndPoint); packet.Free(); }
private void SendPlayerJoinedResponse(int newUserId, Transform newClientTransform) { var packet = Packet.Obtain(); ServerSerializationManager.SerializePlayerJoinedResponse(packet.buffer, newUserId, clients, serverTime, nextSnapshotSeq, minInterpolationBufferElems, newClientTransform.position, newClientTransform.rotation, FullPlayerHealth, PlayerSpeed, GravityValue, clientCount); packet.buffer.Flush(); connectionChannel.Send(packet, connectionIpEndPoint); packet.Free(); }
private void ProcessReceivedCommands(List <Commands> commandsList, int clientId) { var clientData = clients[clientId]; var receivedCommandSequence = -1; foreach (var commands in commandsList) { receivedCommandSequence = commands.Seq; clientData.RecvCommands.Add(commands); } var packet = Packet.Obtain(); ServerSerializationManager.ServerSerializeCommandAck(packet.buffer, receivedCommandSequence); packet.buffer.Flush(); clientData.Channel.Send(packet, clientData.ClientIpEndPoint); packet.Free(); }
private void ProcessReceivedShots(List <Shot> shotsList, int shooterId) { var shooterData = clients[shooterId]; var recvShotSequence = -1; foreach (var shot in shotsList) { recvShotSequence = shot.Seq; var shotPlayerData = clients[shot.ShotPlayerId]; if (shotPlayerData.IsDead) { continue; } shotPlayerData.Health -= ShotDamage; if (shotPlayerData.Health <= 0) { shotPlayerData.IsDead = true; StartCoroutine(ShowDeathAnimation(shotPlayerData, shot.ShotPlayerId)); } foreach (var clientPair in clients) { var clientData = clientPair.Value; SendPlayerShotBroadcast(clientData, shooterId, shot.ShotPlayerId, shotPlayerData.Health); } } var packet = Packet.Obtain(); ServerSerializationManager.ServerSerializeShotAck(packet.buffer, recvShotSequence); packet.buffer.Flush(); shooterData.Channel.Send(packet, shooterData.ClientIpEndPoint); packet.Free(); }