public void OnRaiseClicked() { Transform playerTransform = PlayersParent.transform.Find("Player" + CurrentPlayerIndex); Transform blindsTransform = playerTransform.Find("Blinds"); PlayerWidget playerWidget = playerTransform.gameObject.GetComponent <PlayerWidget>(); if (playerWidget == null) { Debug.LogError("GameController.OnRaiseClicked: PlayerWidget is null. Player index = " + CurrentPlayerIndex); return; } ChipAlignment chipAlignment = playerWidget.ChipAlignment; Hand currentHand = _currentGame.CurrentHand; Player currentPlayer = _currentGame.CurrentPlayer; int defaultAmountToRaise = Math.Min(currentHand.GetHighestBetNotInPot() * 2 - currentPlayer.CurrentBet, currentPlayer.ChipCount); int amountToRaise = _currentAmountToBet > 0 ? _currentAmountToBet : defaultAmountToRaise; PutChipsInfrontPlayer(blindsTransform, amountToRaise, chipAlignment); DisplayPlayerActionText(CurrentPlayerIndex, TurnType.Raise, amountToRaise); if (OnPlayerTurnEnded != null) { OnPlayerTurnEnded(TurnType.Raise, amountToRaise); } }
public void OnBetClicked() { Transform playerTransform = PlayersParent.transform.Find("Player" + CurrentPlayerIndex); Transform blindsTransform = playerTransform.Find("Blinds"); PlayerWidget playerWidget = playerTransform.gameObject.GetComponent <PlayerWidget>(); if (playerWidget == null) { Debug.LogError("GameController.OnBetClicked: PlayerWidget is null. Player index = " + CurrentPlayerIndex); return; } ChipAlignment chipAlignment = playerWidget.ChipAlignment; int amountToBet = _currentAmountToBet > 0 ? _currentAmountToBet : _currentGame.BigBlindSize; PutChipsInfrontPlayer(blindsTransform, amountToBet, chipAlignment); DisplayPlayerActionText(CurrentPlayerIndex, TurnType.Bet, amountToBet); if (OnPlayerTurnEnded != null) { OnPlayerTurnEnded(TurnType.Bet, amountToBet); } }
private void PostPlayerBlind(int playerIndex, int blindSize) { Transform playerTransform = PlayersParent.transform.Find("Player" + playerIndex); Transform blindsTransform = playerTransform.Find("Blinds"); PlayerWidget playerWidget = playerTransform.gameObject.GetComponent <PlayerWidget>(); if (playerWidget == null) { Debug.LogError("GameController.PostPlayerBlind: PlayerWidget is null. Player index = " + playerIndex); return; } ChipAlignment chipAlignment = playerWidget.ChipAlignment; PutChipsInfrontPlayer(blindsTransform, blindSize, chipAlignment); }
public void CreatePlayer(Player newPlayer, int playerIndex) { GameObject playerObject = PlayersParent.transform.Find("Player" + playerIndex).gameObject; PlayerWidget playerWidget = playerObject.GetComponent <PlayerWidget>(); playerWidget.PlayerLink = newPlayer; playerObject.name = "Player" + playerIndex; Transform stackSizeTransform = playerObject.transform.Find("PlayerCard/StackSizeText"); stackSizeTransform.gameObject.GetComponent <Text>().text = newPlayer.ChipCount.ToString(); Transform playerNameTransform = playerObject.transform.Find("PlayerCard/PlayerNameText"); playerNameTransform.gameObject.GetComponent <Text>().text = newPlayer.Name.ToString(); if (newPlayer.Type == PlayerType.Local) { _localPlayerWidget = playerWidget; } }