public override void OnServerAddPlayer(NetworkConnection conn, short playerControllerId) { base.OnServerAddPlayer(conn, playerControllerId); GameObject triviaPlayer = conn.playerControllers[0].gameObject; TriviaGameManagerClient clientManager = triviaPlayer.GetComponent <TriviaGameManagerClient>(); clientManager.RpcGetUsername(); PlayerData playerData = new PlayerData(players.Count, "Player", clientManager); playerData.triviaGameManagerClient.triviaGameManagerServer = this; int playerId = conn.connectionId; playerData.triviaGameManagerClient.playerId = playerId; if (currentQuestionDataClient != null) { SendQuestionToClient(playerData, currentQuestionDataClient); } players[playerId] = playerData; playerIds.Add(playerId); playerCount++; if (gameRunning) { playerData.triviaGameManagerClient.RpcLobbyChangeState(ScreenState.Closed); } }
public PlayerData(int playerId, string username, TriviaGameManagerClient triviaGameManagerClient) { this.triviaGameManagerClient = triviaGameManagerClient; leaderboardData.playerId = playerId; leaderboardData.username = username; }