public void InformAllClientAboutCharacterDisconnect(ServerNetworkManager servNetworkManager, int connectionId) { DisconnectMessage m = new DisconnectMessage(connectionId); foreach (Character player in allCharacters) { servNetworkManager.SendNetworkReliableMessage(m, player.ClientId); } }
public void SendClientPosInfoOfAllOtherPlayers(ServerNetworkManager servNetworkManager, int connectionId) { /* Send client all TransformMessages about all other player characters */ List <TransformMessage> allCharcterPositions = new List <TransformMessage>(); foreach (Character playerCharacter in allCharacters) { if (playerCharacter.ClientId != connectionId) { TransformMessage msg = new TransformMessage(playerCharacter.ClientId); msg.Position.Vect3 = playerCharacter.CharacterObj.transform.position; msg.Rotation.Quaternion = playerCharacter.CharacterObj.transform.rotation; msg.Scale.Vect3 = playerCharacter.CharacterObj.transform.localScale; allCharcterPositions.Add(msg); } } MultipleTranformMessage multipleTransfMsg = new MultipleTranformMessage(allCharcterPositions.ToArray()); servNetworkManager.SendNetworkReliableMessage(multipleTransfMsg, connectionId); }
private void UpdatePlayers(ServerNetworkManager servNetworkManager) { foreach (Character p in allCharacters) { /* Check for players pushing other off the ledge */ int winnerId = p.Update(); if (winnerId != -1) { Character winner = allCharacters.Find(it => it.ClientId == winnerId); winner.CharacterObj.GetComponent <Transform>().localScale += new Vector3(0.5f, 0.5f, 0.5f); winner.CharacterObj.GetComponent <Rigidbody>().mass += 0.5f; /* Update winner player */ TransformMessage transfMsg = new TransformMessage(winner.ClientId); transfMsg.Position.Vect3 = winner.CharacterObj.transform.position; transfMsg.Scale.Vect3 = winner.CharacterObj.transform.localScale; transfMsg.Rotation.Quaternion = winner.CharacterObj.transform.rotation; servNetworkManager.SendNetworkReliableMessage(transfMsg, winner.ClientId); } } }