// Client private void OnInputEnabled(NetworkMessage _networkMessage) { EnableInputMessage msg = _networkMessage.ReadMessage <EnableInputMessage>(); PlayerManager tempPlayer = NetworkHelper.GetObjectByNetIdValue <PlayerManager>((uint)msg.playerId, false); tempPlayer.EnableInput(msg.isEnabled); }
// Server private IEnumerator GameCountdown() { int lastTimeSent = (int)this.countdownTime; // Countdown while (this.countdownTime >= 0.0f) { this.countdownTime -= Time.deltaTime; if ((int)this.countdownTime < lastTimeSent) { lastTimeSent = (int)this.countdownTime; CountdownMessage msg = new CountdownMessage(); msg.countdownString = lastTimeSent <= 0 ? "GO!" : lastTimeSent.ToString(); NetworkServer.SendToAll(CustomMsgType.Countdown, msg); if (msg.countdownString == "GO!") { EnableInputMessage inputMsg = new EnableInputMessage(); for (int i = 0; i < this.numPlayers; i++) { inputMsg.playerId = (int)this.playerInfoList[i].playerObjectId; inputMsg.isEnabled = true; NetworkServer.SendToAll(CustomMsgType.Input, inputMsg); } } } yield return(null); } // Start game this.isPlayingGame = true; }