[ClientRpc]//from server to clients private void RpcGameState(CardConstants.GameTurnState newState, string message, double mainPotinfo) { ClientHandleState(newState, message, mainPotinfo); }//broadcasting the game state and main pot at the start of every state or turn
[Client]//run only on clients side void ClientHandleState(CardConstants.GameTurnState newState, string message, double mainPotinfo) { turnState = newState; string msg = "Client TurnState:" + newState + " : " + message; MainPot = mainPotinfo; MainPotAmount.text = mainPotinfo.ToString(); infoText.text = message; Debug.Log(msg); ClientDisableAllButtons(); switch (newState) { case CardConstants.GameTurnState.ShufflingDeck: { ClientState_StartDeck(); break; } case CardConstants.GameTurnState.WaitingForBets: { ClientState_WaitingForBets(); break; } case CardConstants.GameTurnState.Flop: { break; } case CardConstants.GameTurnState.Turn: { break; } case CardConstants.GameTurnState.River: { break; } case CardConstants.GameTurnState.DealingCards: { ClientState_DealingCards(); break; } case CardConstants.GameTurnState.PlayingPlayerHand: { ClientState_PlayHands(); break; } case CardConstants.GameTurnState.Complete: { ClientState_Complete(); break; } } }//this function responsible to updateing the state of the turn at the client side and starting a function according to the game status
void ServerEnterGameState(CardConstants.GameTurnState newState, string message, double mainPotinfo) { Debug.Log("Server Enter state:" + newState); turnState = newState; RpcGameState(newState, message, mainPotinfo); }//this function responsible for the status of the Game and broadcasting it to the client