public void HandleShowResult(object[] data) { _xocxoc.session.CurrentState = XocXocGameState.SHOW_RESULT; if (_xocxoc.IsDealer()) { DisableDealerButton(); } else if (uiPlayerMaster.gameObject.activeSelf) { DisableBuyerButton(); } foreach (var uiGate in uiGates) { uiGate.ShowDataGate(uiGate.allBet, uiGate.meBetOld, false); uiGate.RemoveAllChip(vkChipPool); uiGate.RemoveMeChip(vkChipPool); } int result = int.Parse(data[0].ToString()); SRSXocXocMyWinLose myWinLose = JsonConvert.DeserializeObject <SRSXocXocMyWinLose>(BestHTTP.JSON.Json.Encode(data[1])); List <SRSXocXocPlayerWinLose> playerWinLoses = JsonConvert.DeserializeObject <List <SRSXocXocPlayerWinLose> >(BestHTTP.JSON.Json.Encode(data[2])); StartCoroutine(WaitShowResult(result, myWinLose, playerWinLoses)); }
// 20s for end IEnumerator WaitShowResult(int result, SRSXocXocMyWinLose myWinLose, List <SRSXocXocPlayerWinLose> playerWinLoses) { vkCountDown.StopCountDown(); vkCountDown.gameObject.SetActive(false); List <int> dices = new List <int>(); List <XocXocGate> winGate = new List <XocXocGate>(); switch (result) { case 0: dices = new List <int> { 1, 1, 1, 1 }; winGate.Add(XocXocGate.Even); winGate.Add(XocXocGate.FourDown); break; case 1: dices = new List <int> { 0, 1, 1, 1 }; winGate.Add(XocXocGate.Odd); winGate.Add(XocXocGate.ThreeDown); break; case 2: dices = new List <int> { 1, 1, 0, 0 }; winGate.Add(XocXocGate.Even); break; case 3: dices = new List <int> { 0, 0, 0, 1 }; winGate.Add(XocXocGate.Odd); winGate.Add(XocXocGate.ThreeUp); break; case 4: dices = new List <int> { 0, 0, 0, 0 }; winGate.Add(XocXocGate.Even); winGate.Add(XocXocGate.FourUp); break; } VKCommon.Shuffle(dices); _batdia.InitDice(dices[0], dices[1], dices[2], dices[3]); Database.Instance.UpdateUserMoney(_xocxoc.moneyType, myWinLose.balance); yield return(new WaitForSeconds(1f)); _xocxoc.session.History.Add(result); LoadHistory(); // refund + Banker win double dealerTakeMoney = 0; foreach (var uiGate in uiGates) { if (winGate.Contains(uiGate.gateType)) { uiGate.ShowResult(true); dealerTakeMoney += uiGate.allBet; } else { uiGate.ShowResult(false); Transform transTarget = transSystemChip; if (!string.IsNullOrEmpty(uiGate.accountIdBuyGate)) { var uiPlayerTemp = uiPlayers.FirstOrDefault(a => a._player != null && a._player.AccountId.Equals(uiGate.accountIdBuyGate)); if (uiPlayerTemp != null) { transTarget = uiPlayerTemp.transform; } } MoveWinAuto(ConvertTotalMoneyToChip(uiGate.allBet), uiGate, transTarget); } // anim or refun var winLose = myWinLose.winLose.FirstOrDefault(a => a.Gate == (int)uiGate.gateType); if (winLose != null) { if (_xocxoc.IsDealer()) { // chua lam gi } else { if (winLose.Refund > 0) { uiGate.ShowDataGate(uiGate.allBet, uiGate.meBetOld - winLose.Refund, false); uiGate.ShowNotify("Hoàn tiền\n" + VKCommon.FillColorString(VKCommon.ConvertStringMoney(winLose.Refund), colorRefund)); } } } } yield return(new WaitForSeconds(1.2f)); // show tien an neu la dealer if (_xocxoc.IsDealer() && dealerTakeMoney > 0) { uiPlayerMaster.ShowNotify("+" + VKCommon.FillColorString(VKCommon.ConvertStringMoney(dealerTakeMoney), colorWin)); } // load chip me - player double winPrize = 0; foreach (var uiGate in uiGates) { // me if (!_xocxoc.IsDealer()) { var winLose = myWinLose.winLose.FirstOrDefault(a => a.Gate == (int)uiGate.gateType); if (winLose != null) { if (winLose.Prize > 0) { winPrize += winLose.Prize; MoveWinAuto(ConvertTotalMoneyToChip(winLose.Prize), uiGate, imgMyAvatar.transform); } } } // player if (winGate.Contains(uiGate.gateType)) { foreach (var uiPlayerTemp in uiPlayers) { if (uiPlayerTemp._player != null && uiPlayerTemp.gateBets.ContainsKey(uiGate.gateType)) { MoveWinAuto(ConvertTotalMoneyToChip(uiPlayerTemp.gateBets[uiGate.gateType] * uiGate.multiReward), uiGate, uiPlayerTemp.transform); } } } // gate uiGate.ShowDataGate(0, 0, false); } yield return(new WaitForSeconds(1.2f)); // show money if (winPrize > 0) { AudioAssistant.Instance.PlaySoundGame(_config.gameId, _config.audioThang); SetNotifyWinLose(VKCommon.FillColorString("+" + VKCommon.ConvertStringMoney(winPrize), colorWin)); } else if (winPrize < 0) { AudioAssistant.Instance.PlaySoundGame(_config.gameId, _config.audioThua); } else { AudioAssistant.Instance.PlaySoundGame(_config.gameId, _config.audioThang); } foreach (var playerData in playerWinLoses) { var uiPlayer = uiPlayers.FirstOrDefault(a => a.IsPlayer(playerData.AccountId)); if (uiPlayer != null) { if (playerData.TotalPrize > 0) { uiPlayer.ShowNotify(VKCommon.FillColorString("+" + VKCommon.ConvertStringMoney(playerData.TotalPrize), colorWin)); uiPlayer.UpdatePlayer(playerData.Balance); } } else if (uiPlayerMaster.gameObject.activeSelf && uiPlayerMaster.IsPlayer(playerData.AccountId)) { uiPlayerMaster.UpdatePlayer(playerData.Balance); } } if (_xocxoc.session.TotalPlayer == 1 && uiPlayerMaster.gameObject.activeSelf) { yield return(new WaitForSeconds(2f)); // fake Update State if (_xocxoc.session.TotalPlayer == 1) { object[] fakeData = new object[4]; fakeData[0] = "0"; fakeData[1] = "0"; fakeData[2] = _xocxoc.session.SessionId; fakeData[3] = _xocxoc.myData.AccountId; HandleChangeState(fakeData); } } }