void Instance_onFinishGame(ResponseFinishGame obj) { if (PokerObserver.Game.IsMainPlayerSatDown) { SetEnableButtonType(EButtonType.InGame); } }
void Instance_onFinishGame(ResponseFinishGame data) { StopTimer(); if (currentBet != null) { NGUITools.SetActive(currentBet.gameObject, false); } ResponseFinishCardPlayer cardPlayer = Array.Find <ResponseFinishCardPlayer>(data.players, p => p.userName == this.data.userName); if (cardPlayer != null && cardPlayer.cards != null) { if (PokerObserver.Game.IsMainPlayer(cardPlayer.userName)) { return; } if (cardOnHands != null) { //FP-128 Người chơi bỏ bài, chờ ván mới, đứng xem không nhìn thấy bài tay của những người chơi so bài bool isFaceUp = PokerObserver.Game.GetTotalPlayerNotFold > 1; if (isFaceUp) { for (int i = 0; i < cardPlayer.cards.Length; i++) { cardOnHands[i].GetComponent <PokerCardObject>().SetDataCard(new PokerCard(cardPlayer.cards[i])); cardOnHands[i].transform.parent = side.positionCardGameEnd[i].transform; cardOnHands[i].transform.localRotation = Quaternion.identity; cardOnHands[i].transform.localPosition = Vector3.zero; cardOnHands[i].transform.localScale = Vector3.one; } } } } }
IEnumerator _onFinishGame(ResponseFinishGame responseData) { UnMarkPot(); PokerObserver.Game.IsClientListening = false; PokerObserver.Instance.isWaitingFinishGame = true; float totalTimeFinishGame = responseData.time / 1000f; float waitTimeViewResultCard = totalTimeFinishGame > 2f ? 1f : 0f; float timeEffectPot = totalTimeFinishGame - waitTimeViewResultCard; if (responseData.pots.Length > 0) timeEffectPot /= responseData.pots.Length; bool isFaceUp = PokerObserver.Game.GetTotalPlayerNotFold > 1; if (isFaceUp) { if (responseData.dealComminityCards.Length == 5) { int[] threeCard = new int[3]; Array.Copy(responseData.dealComminityCards, 0, threeCard, 0, 3); CreateCardDeal(threeCard); yield return new WaitForSeconds(1.0f); int[] cardFouth = new int[1]; Array.Copy(responseData.dealComminityCards, 3, cardFouth, 0, 1); CreateCardDeal(cardFouth); yield return new WaitForSeconds(1.0f); int[] cardFive = new int[1]; Array.Copy(responseData.dealComminityCards, 4, cardFive, 0, 1); CreateCardDeal(cardFive); } else { CreateCardDeal(responseData.dealComminityCards); } } #region SET RESULT TITLE PokerPlayerUI[] playerUI = GameObject.FindObjectsOfType<PokerPlayerUI>(); for (int i = 0; i < playerUI.Length; i++) { for (int j = 0; j < responseData.players.Length; j++) { if (playerUI[i].UserName == responseData.players[j].userName) playerUI[i].SetTitle(isFaceUp ? UTF8Encoder.DecodeEncodedNonAsciiCharacters(responseData.players[j].ranking) : null); } } #endregion yield return new WaitForSeconds(waitTimeViewResultCard * 3 / 4f); #region UPDATE CARD PER POTS SUMMARY foreach (ResponseResultSummary summary in responseData.pots) { ResponseMoneyExchange playerWin = Array.Find<ResponseMoneyExchange>(summary.players, p => p.winner); List<string> lstWinner = new List<string>(); foreach (ResponseMoneyExchange item in summary.players) { if (item.winner) { lstWinner.Add(item.userName); if (PokerObserver.Game.IsMainPlayer(item.userName)) { PuSound.Instance.Play(SoundType.PlayerWin); string rankWin = Array.Find<ResponseFinishCardPlayer>(responseData.players, rdp => rdp.userName == item.userName).ranking; if (!string.IsNullOrEmpty(PokerObserver.Game.mUserInfo.info.facebookId)) StartCoroutine(gpView.ShowBtnShareFacebook(UTF8Encoder.DecodeEncodedNonAsciiCharacters(rankWin), 3f)); } } } if (potContainer != null && playerWin != null) { string rankWin = Array.Find<ResponseFinishCardPlayer>(responseData.players, rdp => rdp.userName == playerWin.userName).ranking; RankEndGameModel playerWinRank = new RankEndGameModel(UTF8Encoder.DecodeEncodedNonAsciiCharacters(rankWin)); if (lstWinner.Count > 0) { for (int i = 0; i < lstWinner.Count(); i++) if (dictPlayerObject.ContainsKey(lstWinner[i])) dictPlayerObject[lstWinner[i]].GetComponent<PokerPlayerUI>().SetResult(true); } potContainer.SummaryPot(summary, timeEffectPot); if (isFaceUp) { List<GameObject> listHightlight = new List<GameObject>(); List<GameObject> listMask = new List<GameObject>(); List<int> list = new List<int>(); if (playerWinRank != null) DialogService.Instance.ShowDialog(playerWinRank); else Logger.LogError("Can't found player Win"); foreach (ResponseMoneyExchange item in summary.players) { if (item.winner) { list.AddRange(item.cards); listHightlight.AddRange(cardsDeal.FindAll(o => list.Contains(o.GetComponent<PokerCardObject>().card.cardId))); } } listMask = cardsDeal.FindAll(o => listHightlight.Contains(o) == false); foreach (GameObject card in listMask) card.GetComponent<PokerCardObject>().SetMask(true); for (int i = 0; i < 20; i++) { listHightlight.ForEach(o => o.GetComponent<PokerCardObject>().SetHighlight(i % 2 == 0)); yield return new WaitForSeconds(timeEffectPot / 20f); } listHightlight.ForEach(o => o.GetComponent<PokerCardObject>().SetHighlight(false)); listMask.ForEach(o => o.GetComponent<PokerCardObject>().SetMask(false)); playerWinRank.DestroyUI(); yield return new WaitForEndOfFrame(); } else yield return new WaitForSeconds(timeEffectPot); if (lstWinner.Count > 0) { for (int i = 0; i < lstWinner.Count(); i++) if (dictPlayerObject.ContainsKey(lstWinner[i])) dictPlayerObject[lstWinner[i]].GetComponent<PokerPlayerUI>().SetResult(false); } } } #endregion yield return new WaitForSeconds(waitTimeViewResultCard / 4f); // Reset Result title if (isFaceUp) Array.ForEach<PokerPlayerUI>(playerUI, p => { if (p != null) p.SetTitle(null); }); ResetNewRound(); PokerObserver.Instance.isWaitingFinishGame = false; PokerObserver.Game.EndFinishGame(); PokerObserver.Game.IsClientListening = true; }
void Instance_onFinishGame(ResponseFinishGame responseData) { StartCoroutine(_onFinishGame(responseData)); }
void Instance_onFinishGame(ResponseFinishGame data) { StopTimer(); if (currentBet != null) NGUITools.SetActive(currentBet.gameObject, false); ResponseFinishCardPlayer cardPlayer = Array.Find<ResponseFinishCardPlayer>(data.players, p => p.userName == this.data.userName); if (cardPlayer != null && cardPlayer.cards != null) { if (PokerObserver.Game.IsMainPlayer(cardPlayer.userName)) return; if (cardOnHands != null) { //FP-128 Người chơi bỏ bài, chờ ván mới, đứng xem không nhìn thấy bài tay của những người chơi so bài bool isFaceUp = PokerObserver.Game.GetTotalPlayerNotFold > 1; if (isFaceUp) { for (int i = 0; i < cardPlayer.cards.Length; i++) { cardOnHands[i].GetComponent<PokerCardObject>().SetDataCard(new PokerCard(cardPlayer.cards[i])); cardOnHands[i].transform.parent = side.positionCardGameEnd[i].transform; cardOnHands[i].transform.localRotation = Quaternion.identity; cardOnHands[i].transform.localPosition = Vector3.zero; cardOnHands[i].transform.localScale = Vector3.one; } } } } }
void Instance_onFinishGame(ResponseFinishGame obj) { if (PokerObserver.Game.IsMainPlayerSatDown) SetEnableButtonType(EButtonType.InGame); }
IEnumerator _onFinishGame(ResponseFinishGame responseData) { UnMarkPot(); PokerObserver.Game.IsClientListening = false; PokerObserver.Instance.isWaitingFinishGame = true; float totalTimeFinishGame = responseData.time / 1000f; float waitTimeViewResultCard = totalTimeFinishGame > 2f ? 1f : 0f; float timeEffectPot = totalTimeFinishGame - waitTimeViewResultCard; if (responseData.pots.Length > 0) { timeEffectPot /= responseData.pots.Length; } bool isFaceUp = PokerObserver.Game.GetTotalPlayerNotFold > 1; if (isFaceUp) { if (responseData.dealComminityCards.Length == 5) { int[] threeCard = new int[3]; Array.Copy(responseData.dealComminityCards, 0, threeCard, 0, 3); CreateCardDeal(threeCard); yield return(new WaitForSeconds(1.0f)); int[] cardFouth = new int[1]; Array.Copy(responseData.dealComminityCards, 3, cardFouth, 0, 1); CreateCardDeal(cardFouth); yield return(new WaitForSeconds(1.0f)); int[] cardFive = new int[1]; Array.Copy(responseData.dealComminityCards, 4, cardFive, 0, 1); CreateCardDeal(cardFive); } else { CreateCardDeal(responseData.dealComminityCards); } } #region SET RESULT TITLE PokerPlayerUI[] playerUI = GameObject.FindObjectsOfType <PokerPlayerUI>(); for (int i = 0; i < playerUI.Length; i++) { for (int j = 0; j < responseData.players.Length; j++) { if (playerUI[i].UserName == responseData.players[j].userName) { playerUI[i].SetTitle(isFaceUp ? UTF8Encoder.DecodeEncodedNonAsciiCharacters(responseData.players[j].ranking) : null); } } } #endregion yield return(new WaitForSeconds(waitTimeViewResultCard * 3 / 4f)); #region UPDATE CARD PER POTS SUMMARY foreach (ResponseResultSummary summary in responseData.pots) { ResponseMoneyExchange playerWin = Array.Find <ResponseMoneyExchange>(summary.players, p => p.winner); List <string> lstWinner = new List <string>(); foreach (ResponseMoneyExchange item in summary.players) { if (item.winner) { lstWinner.Add(item.userName); if (PokerObserver.Game.IsMainPlayer(item.userName)) { PuSound.Instance.Play(SoundType.PlayerWin); string rankWin = Array.Find <ResponseFinishCardPlayer>(responseData.players, rdp => rdp.userName == item.userName).ranking; if (!string.IsNullOrEmpty(PokerObserver.Game.mUserInfo.info.facebookId)) { StartCoroutine(gpView.ShowBtnShareFacebook(UTF8Encoder.DecodeEncodedNonAsciiCharacters(rankWin), 3f)); } } } } if (potContainer != null && playerWin != null) { string rankWin = Array.Find <ResponseFinishCardPlayer>(responseData.players, rdp => rdp.userName == playerWin.userName).ranking; RankEndGameModel playerWinRank = new RankEndGameModel(UTF8Encoder.DecodeEncodedNonAsciiCharacters(rankWin)); if (lstWinner.Count > 0) { for (int i = 0; i < lstWinner.Count(); i++) { if (GetPlayerUI(lstWinner[i]) != null) { GetPlayerUI(lstWinner[i]).SetResult(true); } } } potContainer.SummaryPot(summary, timeEffectPot); if (isFaceUp) { List <GameObject> listHightlight = new List <GameObject>(); List <GameObject> listMask = new List <GameObject>(); List <int> list = new List <int>(); if (playerWinRank != null) { DialogService.Instance.ShowDialog(playerWinRank); } else { Logger.LogError("Can't found player Win"); } foreach (ResponseMoneyExchange item in summary.players) { if (item.winner) { list.AddRange(item.cards); listHightlight.AddRange(cardsDeal.FindAll(o => list.Contains(o.GetComponent <PokerCardObject>().card.cardId))); } } listMask = cardsDeal.FindAll(o => listHightlight.Contains(o) == false); foreach (GameObject card in listMask) { card.GetComponent <PokerCardObject>().SetMask(true); } for (int i = 0; i < 20; i++) { listHightlight.ForEach(o => o.GetComponent <PokerCardObject>().SetHighlight(i % 2 == 0)); yield return(new WaitForSeconds(timeEffectPot / 20f)); } listHightlight.ForEach(o => o.GetComponent <PokerCardObject>().SetHighlight(false)); listMask.ForEach(o => o.GetComponent <PokerCardObject>().SetMask(false)); playerWinRank.DestroyUI(); yield return(new WaitForEndOfFrame()); } else { yield return(new WaitForSeconds(timeEffectPot)); } if (lstWinner.Count > 0) { for (int i = 0; i < lstWinner.Count(); i++) { if (GetPlayerUI(lstWinner[i]) != null) { GetPlayerUI(lstWinner[i]).SetResult(false); } } } } } #endregion yield return(new WaitForSeconds(waitTimeViewResultCard / 4f)); // Reset Result title if (isFaceUp) { Array.ForEach <PokerPlayerUI>(playerUI, p => { if (p != null) { p.SetTitle(null); } }); } Array.ForEach <PokerPlayerUI>(playerUI, p => p.ResetDataOnFinishGame()); #region Handle Disconnect and Reconnect foreach (PokerPlayerUI p in listPlayerQuit) { dictPlayerObject.Remove(p.UserName); GameObject.Destroy(p.gameObject); } listPlayerQuit.Clear(); foreach (string key in dictReJoinGame.Keys) { dictPlayerObject.Add(key, dictReJoinGame[key]); } dictReJoinGame.Clear(); #endregion ResetNewRound(); PokerObserver.Instance.isWaitingFinishGame = false; PokerObserver.Game.EndFinishGame(); PokerObserver.Game.IsClientListening = true; }
void Instance_onFinishGame(ResponseFinishGame responseData) { StartCoroutine(_onFinishGame(responseData)); }