public PlayerInfo GetPlayerInfoFromTurn(EntityTurn turn) { for (int i = 0; i < connectedPlayers.Count; i++) { if ((int)GameManager.currentTurn == (int)turn) { return(connectedPlayers[i]); } } // Cas only one player return(PlayerInfo.Instance); }
// Here i know that public void TryStartGame(int playerIndex) { isPlayerReadyForStartGame[playerIndex] = true; bool allPlayerAreReady = true; for (int i = 0; i < connectedPlayers.Count; i++) { if (!isPlayerReadyForStartGame[i]) { allPlayerAreReady = false; } } if (allPlayerAreReady) { EntityTurn randPlayerTurn = (EntityTurn)Random.Range(0, connectedPlayers.Count); PlayerInfo currentPlayerInfo = GetPlayerInfoFromTurn(randPlayerTurn); PlayerInfo otherPlayerInfo = GetOtherPlayerInfo(currentPlayerInfo); // Choose the seed of the map here int mapSeed = 0; RpcPropagateStartGame(mapSeed, currentPlayerInfo.playerIndex, otherPlayerInfo.playerName, otherPlayerInfo.playerColor); } }
public void ChangeTurn(int playerIndex, string otherPlayerName, Color otherPlayerColor) { currentTurn = (EntityTurn)playerIndex; OnGameStateChange(otherPlayerName, otherPlayerColor); }