private void OnDestroy()
 {
     StopAllCoroutines();
     DataManager.instance.userData.RemoveTotalBetInGameInfo(IMiniGameInfo.Type.AnimalRacing);
     animalRacingData = null;
     AnimalRacing_RealTimeAPI.SelfDestruction();
     instance = null;
 }
    void InitData()
    {
        currentState          = State.Bet;
        callbackManager       = new AnimalRacing_CallbackManager();
        animalRacingData      = new AnimalRacingData();
        listProcessPlaying    = new List <IEnumerator>();
        listProcessNonPlaying = new List <IEnumerator>();
        shadowChangeScreen.gameObject.SetActive(false);
        HideIconNotificationChat();
        betManager.InitData();

        screenChat       = ((GameObject)Instantiate(screenChatPrefab, transform)).GetComponent <ScreenChatController>();
        popupChatManager = ((GameObject)Instantiate(popupChatManagerPrefab, transform)).GetComponent <PopupChatManager>();

        // -------- Init Callback -------- //
        InitAllCallback();
        // ------------------------------- //
    }
示例#3
0
    public IEnumerator DoActionShowEffectUpdateGold()
    {
        AnimalRacingData _animalRacingData       = AnimalRacing_GamePlay_Manager.instance.animalRacingData;
        Vector3          _posStartGoldWin        = Vector3.zero;
        Vector3          _posEndGoldWin          = Vector3.zero;
        Vector3          _posStartPanelGoldBonus = Vector3.zero;

        int _animalIndexWin = (int)_animalRacingData.currentResultData.animalWin;

        _posStartGoldWin = panelTableBet.listBetOption[_animalIndexWin].imgAvatar.transform.position;

        SetUpShadowTable(_animalRacingData.currentResultData.animalWin, true);

        if (AnimalRacing_GamePlay_Manager.instance.CanPlayMusicAndSfx())
        {
            MyAudioManager.instance.PlaySfx(AnimalRacing_GamePlay_Manager.instance.myAudioInfo.sfx_HighlightPanelWin);
        }
        yield return(DoActionHighlightIndexBet(_animalRacingData.currentResultData.animalWin));

        if (_animalRacingData.currentResultData.listGoldUpdate.Count > 0)
        {
            bool _needWait = false;
            for (int i = 0; i < _animalRacingData.currentResultData.listGoldUpdate.Count; i++)
            {
                if (_animalRacingData.currentResultData.listGoldUpdate[i].betUnit <= 0)
                {
                    continue;
                }
                if (_animalRacingData.currentResultData.listGoldUpdate[i].sessionId == DataManager.instance.userData.sessionId)
                {
                    _needWait = true;
                    _posStartPanelGoldBonus = panelUserInGame.userAvata.transform.position;
                    _posEndGoldWin          = panelUserInGame.userAvata.transform.position;

                    StartCoroutine(MyConstant.DoActionShowPopupWinGold(panelBonusGoldPrefab.gameObject, effectPoolManager, myCanvasGroup.transform
                                                                       , _posStartPanelGoldBonus, 1.1f, _animalRacingData.currentResultData.listGoldUpdate[i].betUnit
                                                                       , () => {
                        panelUserInGame.RefreshGoldInfo();
                        if (AnimalRacing_GamePlay_Manager.instance.CanPlayMusicAndSfx())
                        {
                            MyAudioManager.instance.PlaySfx(GameInformation.instance.globalAudioInfo.sfx_Gold);
                        }
                    }));
                    StartCoroutine(MyConstant.DoActionShowEffectGoldFly(goldObjectPrefab, effectPoolManager, AnimalRacing_GamePlay_Manager.instance.sortingLayerManager.sortingLayerInfo_GoldObject
                                                                        , _posStartGoldWin, _posEndGoldWin, 10, 1f, 0.8f));
                }
                else
                {
                    for (int j = 0; j < listOtherPlayerInfo.Count; j++)
                    {
                        if (listOtherPlayerInfo[j].data != null &&
                            listOtherPlayerInfo[j].data.IsEqual(_animalRacingData.currentResultData.listGoldUpdate[i].sessionId))
                        {
                            _needWait = true;
                            _posStartPanelGoldBonus = listOtherPlayerInfo[j].transform.position;
                            _posEndGoldWin          = listOtherPlayerInfo[j].transform.position;

                            StartCoroutine(MyConstant.DoActionShowPopupWinGold(panelBonusGoldPrefab.gameObject, effectPoolManager, myCanvasGroup.transform
                                                                               , _posStartPanelGoldBonus, 1.1f, _animalRacingData.currentResultData.listGoldUpdate[i].betUnit
                                                                               , () => {
                                if (listOtherPlayerInfo[j].data != null &&
                                    listOtherPlayerInfo[j].currentState == PanelPlayerInfoInGameController.State.Show)
                                {
                                    listOtherPlayerInfo[j].RefreshGoldInfo();
                                    if (AnimalRacing_GamePlay_Manager.instance.CanPlayMusicAndSfx())
                                    {
                                        MyAudioManager.instance.PlaySfx(GameInformation.instance.globalAudioInfo.sfx_Gold);
                                    }
                                }
                            }));
                            StartCoroutine(MyConstant.DoActionShowEffectGoldFly(goldObjectPrefab, effectPoolManager, AnimalRacing_GamePlay_Manager.instance.sortingLayerManager.sortingLayerInfo_GoldObject
                                                                                , _posStartGoldWin, _posEndGoldWin, 10, 1f, 0.8f));
                            break;
                        }
                    }
                }
            }
            if (_needWait)
            {
                yield return(Yielders.Get(2f));
            }
            SetUpShadowTable(_animalRacingData.currentResultData.animalWin, false);
        }
        else
        {
            SetUpShadowTable(_animalRacingData.currentResultData.animalWin, false);
        }

        panelListChip.SetFocusChipAgain();

        if (AnimalRacing_GamePlay_Manager.instance.callbackManager.onEndSetUpAfterShowResult != null)
        {
            AnimalRacing_GamePlay_Manager.instance.callbackManager.onEndSetUpAfterShowResult();
            AnimalRacing_GamePlay_Manager.instance.callbackManager.onEndSetUpAfterShowResult = null;
        }
    }
        public AnimalRacing_Result_Data(MessageReceiving _mess, AnimalRacingData _animalRacingData)
        {
            // byte result_index : vị trí về nhất (nếu -1 : lỗi server gold + không đọc tiếp)
            // byte[9][80] : data mô tả cách chạy của 9 animal cược
            // short[9] : 9 tỷ lệ cược mới
            // byte caseCheck
            // ***Xét trường hợp caseCheck
            // caseCheck=69 : không có ai đặt cược
            // caseCheck=-99: lỗi ServerGold
            // caseCheck=1 : xử lý tiền thành công ⟶ đọc tiếp
            //     byte numberPlayer
            //     for(numberPlayer){
            //         short sessionid
            //         byte casePlayer
            //         ***Xét trường hợp casePlayer
            //         casePlayer=-55 : lỗi databasePlayer
            //         casePlayer=-88 : lỗi không đủ tiền ⟶ đọc tiếp
            //             long gold_Limit
            //             long GOLD
            //         casePlayer=1 : xử lý tiền thành công
            //             long gold_Limit
            //             long gold_Win
            //             long goldAdd
            //             long GOLD
            //             int achievement : dựa vào ⟶ gold_Win
            //     }

            animalWin = (AnimalRacing_AnimalController.AnimalType)_mess.readByte();

            listAnimalRunData = new sbyte[9][];
            for (int i = 0; i < 9; i++)
            {
                listAnimalRunData[i] = new sbyte[80]; // chạy 8s, 0.1s cập nhật 1 lần
                for (int j = 0; j < 80; j++)
                {
                    listAnimalRunData[i][j] = _mess.readByte();
                }
            }

            newListCurrentScore = new List <short>();
            for (int i = 0; i < 9; i++)
            {
                newListCurrentScore.Add(_mess.readShort());
            }
            newListGlobalBet = new List <long>();
            for (int i = 0; i < 9; i++)
            {
                newListGlobalBet.Add(0);
            }
            newListMyBet = new List <long>();
            for (int i = 0; i < 9; i++)
            {
                newListMyBet.Add(0);
            }

            listGoldUpdate = new List <GoldUpdateData>();
            valueCheck     = _mess.readByte();
            switch (valueCheck)
            {
            case 1: // cập nhật thành công
                sbyte          _numberPlayer  = _mess.readByte();
                GoldUpdateData _tmpGoldUpdate = null;
                for (int i = 0; i < _numberPlayer; i++)
                {
                    _tmpGoldUpdate = new GoldUpdateData(_mess);
                    listGoldUpdate.Add(_tmpGoldUpdate);
                }
                break;

            case 69: // không có ai đặt cược
                #if TEST
                Debug.Log(">>> Không có ai đặt cược");
                                #endif
                break;

            case -99: // lỗi ServerGold
                #if TEST
                Debug.Log(">>> Lỗi ServerGold");
                                #endif
                break;

            default:
                #if TEST
                Debug.Log(">>> Lỗi không xác định: " + valueCheck);
                                #endif
                break;
            }

            nextTimeToShowResult = System.DateTime.Now.AddMilliseconds(_animalRacingData.duringTime);
        }