A utility class to send simple network messages that only contain an integer.
public static NetSystem.IntegerMessage GetIntegerMessage(int value) { if (_integerMessage == null) { _integerMessage = new NetSystem.IntegerMessage(); } _integerMessage.value = value; return(_integerMessage); }
public void SendSceneLoadedMessage() { if (LogFilter.logDebug) { Debug.Log("NetworkLobbyPlayer SendSceneLoadedMessage"); } NetworkLobbyManager singleton = NetworkManager.singleton as NetworkLobbyManager; if (singleton != null) { IntegerMessage msg = new IntegerMessage(base.playerControllerId); singleton.client.Send(0x2c, msg); } }
public void SendSceneLoadedMessage() { if (LogFilter.logDebug) { Debug.Log("NetworkLobbyPlayer SendSceneLoadedMessage"); } var lobby = NetworkManager.singleton as LobbyManager; if (lobby) { var msg = new IntegerMessage(playerControllerId); lobby.client.Send(MsgType.LobbySceneLoaded, msg); } }
IEnumerator RoundTimer(int seconds) { int currRoundsLeft = roundsToPlay; runningRound = true; while(--seconds > 0) { IntegerMessage msg = new IntegerMessage(); msg.value = seconds; NetworkServer.SendToAll((short)MsgTypes.RoundStart, msg); if (currRoundsLeft == roundsToPlay) yield return new WaitForSeconds(1); else yield return null; } if (currRoundsLeft == roundsToPlay) //defenders won Win(attackingTeam.Enemy()); }
IEnumerator PrepTimer(int seconds) { runningRound = false; while(--seconds > 0) { IntegerMessage msg = new IntegerMessage(); msg.value = seconds; NetworkServer.SendToAll((short)MsgTypes.PrepTimeStart, msg); yield return new WaitForSeconds(1); } foreach (Player p in players) { p.waitingForRound = false; p.controller.controllable = true; } StartCoroutine(RoundTimer(roundSeconds)); }
/// <summary> /// /// <para> /// This is used on clients to tell the server that the client has switched from the lobby to the GameScene and is ready to play. /// </para> /// /// </summary> public void SendSceneLoadedMessage() { if (LogFilter.logDebug) Debug.Log((object) "NetworkLobbyPlayer SendSceneLoadedMessage"); NetworkLobbyManager networkLobbyManager = NetworkManager.singleton as NetworkLobbyManager; if (!(bool) ((Object) networkLobbyManager)) return; IntegerMessage integerMessage = new IntegerMessage((int) this.playerControllerId); networkLobbyManager.client.Send((short) 44, (MessageBase) integerMessage); }
/// <summary> /// /// <para> /// This is used on clients to tell the server that this player is ready for the game to begin. /// </para> /// /// </summary> public void SendReadyToBeginMessage() { if (LogFilter.logDebug) Debug.Log((object) "NetworkLobbyPlayer SendReadyToBeginMessage"); NetworkLobbyManager networkLobbyManager = NetworkManager.singleton as NetworkLobbyManager; if (!(bool) ((Object) networkLobbyManager)) return; // Send the players controller id to server to signal this player as ready IntegerMessage integerMessage = new IntegerMessage((int) this.playerControllerId); networkLobbyManager.client.Send((short) 43, (MessageBase) integerMessage); }