private void HandlePlayerRequestedBackToGame(string playerID) { if (playerID == "") { return; } TableGamePlayer player = GetPlayerByID(playerID); if (player != null) { txtGameLog.text += "\n" + playerID + Constants.MESSAGE_PLAYER_IS_BACK_TO_GAME; Canvas.ForceUpdateCanvases(); if (scrollNote.gameObject.activeSelf) { scrollNote.verticalScrollbar.value = 0; } if (isGameCompleted && playerID.Equals(NetworkManager.Instance.playerID)) { btnSitoutNextHand.interactable = true; sitOutCounter = 0; } } }
private void HandlePlayerRequestedSitout(string playerID) { if (playerID == "") { return; } TableGamePlayer player = GetPlayerByID(playerID); if (player != null) { txtGameLog.text += "\n" + playerID + Constants.MESSAGE_PLAYER_IS_SITOUT; Canvas.ForceUpdateCanvases(); if (scrollNote.gameObject.activeSelf) { scrollNote.verticalScrollbar.value = 0; } if (player.playerID.Equals(NetworkManager.Instance.playerID)) { DebugLog.Log("Back to game button enabled"); btnBackToGame.interactable = true; } } }
private void DestroyPlayer(string playerID) { TableGamePlayer p = GetPlayerByID(playerID); if (p) { allTableGamePlayers.Remove(p); Destroy(p.gameObject); } }
public void DistributeTableGameCards() { for (int i = 0; i < GameManager.Instance.allTableGamePlayers.Count; i++) { TableGamePlayer p = GameManager.Instance.allTableGamePlayers [i]; if (p.playerInfo.Player_Status != (int)PLAYER_STATUS.ACTIVE && p.playerInfo.Player_Status != (int)PLAYER_STATUS.ABSENT && p.playerInfo.Player_Status != (int)PLAYER_ACTION.ALLIN) { continue; } for (int j = 0; j < 2; j++) { GameObject card = Instantiate(cardPrefab, dealerPosition.position, Quaternion.identity) as GameObject; card.transform.SetParent(j == 0 ? p.card1Position : p.card2Position); card.transform.localScale = Vector3.one; if (p.playerID.Equals(NetworkManager.Instance.playerID)) { card.GetComponent <CardFlipAnimation> ().DisplayCardWithoutAnimation(j == 0 ? p.card1 : p.card2); } Vector3 targetPos = j == 0 ? p.card1Position.position : p.card2Position.position; StartCoroutine(MoveCardTo(card.transform, targetPos)); } } // Generate cards for dealer for (int i = 0; i < 2; i++) { GameObject card = Instantiate(dealerCardPrefab, dealerPosition.position, Quaternion.identity) as GameObject; card.transform.SetParent(i == 0 ? GameManager.Instance.dealerCard1.transform : GameManager.Instance.dealerCard2.transform); card.transform.localScale = Vector3.one; if (i == 0) { GameManager.Instance.dealerFirstCard = card.GetComponent <CardFlipAnimation> (); } else { GameManager.Instance.dealerSecondCard = card.GetComponent <CardFlipAnimation> (); } Vector3 targetPos = i == 0 ? GameManager.Instance.dealerCard1.transform.position : GameManager.Instance.dealerCard2.transform.position; StartCoroutine(MoveCardTo(card.transform, targetPos)); SoundManager.Instance.PlayCardSuffleSound(Camera.main.transform.position); } }
public void GenerateTablePlayerCardsForWaitingPlayer() { for (int i = 0; i < GameManager.Instance.allTableGamePlayers.Count; i++) { TableGamePlayer p = GameManager.Instance.allTableGamePlayers [i]; if (p.playerInfo.Player_Status == (int)PLAYER_STATUS.WAITING || p.playerInfo.Player_Status == (int)PLAYER_ACTION.ACTION_WAITING_FOR_GAME) { continue; } for (int j = 0; j < 2; j++) { if (j == 0 && p.card1Position.childCount > 0) { continue; } if (j == 1 && p.card2Position.childCount > 0) { continue; } Vector3 targetPos = j == 0 ? p.card1Position.position : p.card2Position.position; GameObject card = Instantiate(cardPrefab, targetPos, Quaternion.identity) as GameObject; card.transform.SetParent(j == 0 ? p.card1Position : p.card2Position); card.transform.localScale = Vector3.one; } } // Generate cards for dealer for (int i = 0; i < 2; i++) { Vector3 targetPos = i == 0 ? GameManager.Instance.dealerCard1.transform.position : GameManager.Instance.dealerCard2.transform.position; GameObject card = Instantiate(dealerCardPrefab, targetPos, Quaternion.identity) as GameObject; card.transform.SetParent(i == 0 ? GameManager.Instance.dealerCard1.transform : GameManager.Instance.dealerCard2.transform); card.transform.localScale = Vector3.one; if (i == 0) { GameManager.Instance.dealerFirstCard = card.GetComponent <CardFlipAnimation> (); } else { GameManager.Instance.dealerSecondCard = card.GetComponent <CardFlipAnimation> (); } } }
private void HandleOnPlayerInfoReceived(string sender, string info) { Debug.Log(info); btnSitoutNextHand.interactable = false; PlayerInfo playerInfo = JsonUtility.FromJson <PlayerInfo> (info); // Need to decrease one index. Seat index from server is started from 1 playerInfo.Player_Position--; if (playerInfo.Player_Name.Equals(Constants.FIELD_PLAYER_NAME_DEALER)) { dealerInfo = playerInfo; } else { // Need to decrease one index. Dealer is always on first seat. playerInfo.Player_Position--; TableGamePlayer player = GetPlayerByID(playerInfo.Player_Name); if (player) { player.playerID = playerInfo.Player_Name; player.buyinChips = playerInfo.Player_BuyIn_Chips; player.card1 = playerInfo.Card1; player.card2 = playerInfo.Card2; player.playerInfo = playerInfo; player.seatIndex = playerInfo.Player_Position; player.totalChips = playerInfo.Player_Total_Play_Chips; player.totalRealMoney = playerInfo.Player_Total_Real_Chips; player.SetPlayerName(); if (playerInfo.Player_Status == (int)PLAYER_STATUS.SIT_OUT) { player.imgSitout.gameObject.SetActive(true); } player.DisplayTotalChips(); return; } if (playerInfo.Player_Status == (int)PLAYER_STATUS.ELIMINATED && playerInfo.Player_Name.Equals(NetworkManager.Instance.playerID)) { // if (Application.platform == RuntimePlatform.WebGLPlayer) // UIManager.Instance.BackToLobby (); // else { // LoginScript.loginDetails = null; // SceneManager.LoadScene (SceneManager.GetActiveScene ().name); // } UIManager.Instance.backConfirmationPanel.OnYesButtonTap(); return; } GameObject obj = Instantiate(whoopAssPlayerPrefab, playerSeats [playerInfo.Player_Position].position, Quaternion.identity) as GameObject; TableGamePlayer tableGamePlayer = obj.GetComponent <TableGamePlayer> (); tableGamePlayer.playerID = playerInfo.Player_Name; tableGamePlayer.buyinChips = playerInfo.Player_BuyIn_Chips; tableGamePlayer.card1 = playerInfo.Card1; tableGamePlayer.card2 = playerInfo.Card2; tableGamePlayer.playerInfo = playerInfo; tableGamePlayer.seatIndex = playerInfo.Player_Position; tableGamePlayer.totalChips = playerInfo.Player_Total_Play_Chips; tableGamePlayer.totalRealMoney = playerInfo.Player_Total_Real_Chips; tableGamePlayer.SetPlayerName(); tableGamePlayer.GetComponent <CanvasGroup> ().alpha = 0f; if (playerInfo.Player_Status == (int)PLAYER_STATUS.SIT_OUT) { tableGamePlayer.imgSitout.gameObject.SetActive(true); } obj.transform.SetParent(playerSeats [playerInfo.Player_Position]); obj.transform.localScale = Vector3.one; allTableGamePlayers.Add(tableGamePlayer); if (playerInfo.Player_Name.Equals(NetworkManager.Instance.playerID)) { ownTablePlayer = tableGamePlayer; CentralizeOwnPlayer(); btnAddChips.interactable = true; } else { tableGamePlayer.SetChipsPosition(); } if (tableGamePlayer.buyinChips <= 0) { tableGamePlayer.GetComponent <CanvasGroup> ().alpha = .4f; } else { tableGamePlayer.GetComponent <CanvasGroup> ().alpha = 1f; } HandleWaitingPlayer(playerInfo); } }