Example #1
0
    IEnumerator DoActionShowResult()
    {
        if (currentGameState == GameState.ShowResult)
        {
            Debug.LogError("Đang show result rồi");
            yield break;
        }

        KoprokData.Koprok_Result_Data _resultData = koprokData.processResultData[0];

        currentGameState = GameState.ShowResult;

        // ---- Merge dữ liệu ---- //
        Koprok_GamePlay_Manager.IndexBet _slot1 = (Koprok_GamePlay_Manager.IndexBet)_resultData.dice[0];
        Koprok_GamePlay_Manager.IndexBet _slot2 = (Koprok_GamePlay_Manager.IndexBet)_resultData.dice[1];
        Koprok_GamePlay_Manager.IndexBet _slot3 = (Koprok_GamePlay_Manager.IndexBet)_resultData.dice[2];
        koprokData.listHistory.Insert(0, new KoprokData.Koprok_History_Data(_slot1, _slot2, _slot3));

        koprokData.CheckListHistoryAgain();
        koprokData.ResetTableBet();
        koprokData.nextTimeToShowResult    = _resultData.nextTimeToShowResult;
        DataManager.instance.userData.gold = _resultData.GOLD;
        DataManager.instance.userData.SetTotalBetInGameInfo(IMiniGameInfo.Type.Koprok, 0);

        if (_resultData.caseCheck == 1)
        {
            AchievementDetail _achievementDetail = DataManager.instance.achievementData.GetAchievementDetail(IMiniGameInfo.Type.Koprok);
            if (_achievementDetail != null)
            {
                if (_resultData.goldProcess > 0)
                {
                    _achievementDetail.countWin = _resultData.achievement;
                }
                else if (_resultData.goldProcess < 0)
                {
                    _achievementDetail.countLose = _resultData.achievement;
                }
                else
                {
                    _achievementDetail.countDraw = _resultData.achievement;
                }
            }
            else
            {
                Debug.LogError(">>> _achievementDetail is null");
            }
        }
        else if (_resultData.caseCheck == -88)
        {
            PopupManager.Instance.CreatePopupMessage(MyLocalize.GetString(MyLocalize.kError)
                                                     , MyLocalize.GetString("Error/GamePlay_BetError_0")
                                                     , _resultData.caseCheck.ToString()
                                                     , MyLocalize.GetString(MyLocalize.kOk));
        }
        // ----------------------- //

        if (callbackManager != null && callbackManager.onStartShowResult != null)
        {
            callbackManager.onStartShowResult();
        }

        List <Sprite> _listSpriteBetWin = new List <Sprite>();

        for (int i = 0; i < _resultData.dice.Count; i++)
        {
            _listSpriteBetWin.Add(spriteIconBet[(int)_resultData.dice[i]]);
        }
        diskShock.SetItemInfo(_listSpriteBetWin, true, true);

        SetUpShadowTable(null, true);
        yield return(StartCoroutine(diskShock.DoActionShowResult(myAudioInfo.sfx_DiceMove)));

        yield return(StartCoroutine(DoActionHighlightIndexBet(_resultData.dice)));

        if (_resultData.betUnit > 0)
        {
            StartCoroutine(MyConstant.DoActionShowPopupWinGold(panelBonusGoldPrefab, effectPoolManager, myCanvas.transform
                                                               , showEffPanelGoldBonusEffPlaceHolder.position, 1.1f, _resultData.betUnit
                                                               , () => {
                panelUserInGame.RefreshGoldInfo();
            }));
            List <IndexBet> _myBetWin = new List <IndexBet>();
            for (int i = 0; i < _resultData.dice.Count; i++)
            {
                if (koprokData.myIndexBet.Contains(_resultData.dice[i]))
                {
                    _myBetWin.Add(_resultData.dice[i]);
                }
            }
            yield return(StartCoroutine(DoActionShowEffWinGoldAtIndex(_myBetWin, (Vector2)iconGoldHolder.position)));
        }

        yield return(StartCoroutine(diskShock.DoActionShockAgainAndReset(myAudioInfo.sfx_DiceMove, myAudioInfo.sfx_DiceShake)));

        SetUpShadowTable(_resultData.dice, false);

        if (callbackManager != null && callbackManager.onEndShowResult != null)
        {
            callbackManager.onEndShowResult();
        }

        _resultData = null;
        koprokData.processResultData.RemoveAt(0);

        SetBetAgain();
    }