// Client public void OnScoreMessage(NetworkMessage _networkMessage) { Debug.Log("Update score msg received"); GameScoresMessage msg = _networkMessage.ReadMessage <GameScoresMessage>(); this.canvasManager.OnScoreUpdate(msg.scores); }
// Server private IEnumerator ScoreRoutine() { yield return(new WaitUntil(() => this.isPlayingGame == true)); while (this.isPlayingGame) { // Traverse players for (int i = 0; i < this.numPlayers; i++) { if (playerInfoList[i].hasFlag) { this.playerScoreList[i] += 1; Debug.Log("Add score for player " + i.ToString()); yield return(new WaitForSeconds(this.scoreAdditionInterval)); // Send score message GameScoresMessage msg = new GameScoresMessage(); msg.scores = this.playerScoreList.ToArray(); NetworkServer.SendToAll(CustomMsgType.GameScore, msg); } } yield return(null); } yield return(null); }