public void HubShowResult(object[] data) { SRSBauCuaGameResult bcResult = new SRSBauCuaGameResult(data); _baucua.session.State = BauCuaState.SHAKING; AudioAssistant.Instance.PlaySoundGame(_GAMEID, _STIMEOUT); vkCountDown.StopCountDown(); vkCountDown.StartCoundown((float)bcResult.elapsed); cacheGold = new MAccountInfoUpdateGold(_account.Gold + bcResult.GetGoldAdd()); cacheCoin = new MAccountInfoUpdateCoin(_account.Coin + bcResult.GetCoinAdd()); // add history _baucua.histories.Insert(0, new SRSBauCuaHistoryItem { SessionId = txtId.text, Dice1 = bcResult.result.Dice1, Dice2 = bcResult.result.Dice2, Dice3 = bcResult.result.Dice3 }); if (_baucua.histories.Count > 20) { _baucua.histories.RemoveAt(_baucua.histories.Count - 1); } StartCoroutine(WaitShowResult(bcResult)); }
// 20s for end IEnumerator WaitShowResult(SRSBauCuaGameResult bcResult) { uiGates.ForEach(a => a.RemoveChip(vkChipPool, uiChips, tranWorld, false)); uiBatDia.InitDice(bcResult.result.Dice1, bcResult.result.Dice2, bcResult.result.Dice3); yield return(new WaitUntil(() => !uiBatDia.isRuning)); foreach (var uiGate in uiGates) { uiGate.ShowResult(bcResult.result.IsWin(uiGate.gate)); } yield return(new WaitForSeconds((float)(bcResult.elapsed / 10))); uiBatDia.ClearUI(); yield return(new WaitForSeconds((float)(bcResult.elapsed / 2.5f))); double moneyWin = 0; foreach (var uiGate in uiGates) { var winlose = bcResult.GetBetWin(_baucua.moneyType, uiGate.gate); if (winlose != null) { moneyWin += winlose.award; } uiGate.ShowWinLose(winlose != null ? winlose.award : 0); } if (moneyWin > 1) { AudioAssistant.Instance.PlaySoundGame(_GAMEID, _SWIN); } LoadHistory(); var layer = UILayerController.Instance.GetLayer <LGameBauCuaStatistic>(); if (layer != null) { layer.LoadStatistic(); } Database.Instance.UpdateUserGold(cacheGold); Database.Instance.UpdateUserCoin(cacheCoin); }