public void CmdGetCard() { ColorCard cc = ColorCardStack.DrawCard(); if (cc.Equals(default(ColorCard))) { // Stack is empty --> Reshuffle ColorCardStack.ReshuffleStack(SpawnedCards); cc = ColorCardStack.DrawCard(); } TargetTakeCard(connectionToClient, cc); if (player.GetCurrentDrawCount() > 0) { player.SetCurrentDrawCount(player.GetCurrentDrawCount() - 1); } int index = networkManager.GetConnectedClients().IndexOf(connectionToClient); Player.playerCardsCount[index] += 1; player.SetCardsCount(Player.playerCardsCount); // Sync new card count with all clients RpcSetPlayerCardsCount(Player.playerCardsCount); }
public void CmdSignalPlayerReady() { int index = networkManager.GetConnectedClients().IndexOf(connectionToClient); player.SetPlayerReady(index); // Start game if (player.AllPlayersReady()) { // Spawn tables CmdSpawnTables(); // Spawn initial card ColorCard cc; do { cc = ColorCardStack.DrawCard(); CmdSpawnCardOnGameboard(cc); } while (cc.type != ColorCard.Type.STANDARD); // Init card count for each player Player.playerCardsCount = new int[] { 7, 7, 7, 7 }; RpcSetPlayerCardsCount(Player.playerCardsCount); // Sync with clients // Start game player.SetCurrentPlayerIndex(0); // Server starts always first player.SetTurn(true, 0); RpcPlayerIndexChanged(0); } }