Exemple #1
0
    public void Init(SRSSlot25LineConfig config, Slot25lineSignalRServer server, SRSSlot25LineAccount account, AssetBundleSettingItem assetBundleConfig, int roomId, int mType)
    {
        ClearUI();

        _config               = config;
        _server               = server;
        _server.OnSRSEvent    = OnSRSEvent;
        _server.OnSRSHubEvent = OnSRSHubEvent;

        _assetBundleConfig = assetBundleConfig;
        _settingSound      = AudioAssistant.Instance.GetSettingSound(_config.gameId);

        this.accountSpin = account;
        this.accountInfo = Database.Instance.Account();

        this.roomBetId    = roomId;
        this.moneyType    = mType;
        this.roomBetValue = accountSpin.RoomBetValue(roomBetId);

        txtRomBet.SetNumber(roomBetValue);

        SetNotifyFree();
        SetLineSelected(account.GetLineData());

        // event
        OnEventUpdate();

        // update jackpot
        if (_server.jackpots.ContainsKey(roomBetId.ToString()))
        {
            jackpot = _server.jackpots[roomBetId.ToString()];
            UpdateJackpot();
        }

        // Set data
        imgIconMoney.sprite = sprIconMoney[moneyType == MoneyType.GOLD ? 0 : 1];
        vkTxtMyMoney.SetNumber(accountInfo.GetCurrentBalance(moneyType));

        // finish bonus
        if (account.BonusSpinId > 0)
        {
            _server.HubCallFinishBonusGame(moneyType, account.BonusSpinId);
        }
    }
Exemple #2
0
    // quay spin
    IEnumerator WaitMachineFinish(SRSSlot25LineResultSpin result)
    {
        _machine.StartMachineLeftToRight(result.GetSlotData());

        if (!isSieuToc)
        {
            yield return(new WaitForSeconds(0.5f));

            AudioAssistant.Instance.PlaySoundGame(_config.gameId, _config.audioSpin);
        }

        lastResult = result;
        yield return(new WaitUntil(() => !_machine.isRunning));

        if (accountSpin.FreeSpins <= 0 || result.Balance > 0)
        {
            Database.Instance.UpdateUserMoney(moneyType, result.Balance);
        }

        if ((result.PrizeLines != null && result.PrizeLines.Count > 0) || result.IsBonusGame())
        {
            // show line win
            List <int> itemBonus = _machine.GetListItemBonus();

            List <int> lineTemps = new List <int>();
            List <int> itemWins  = new List <int>();
            foreach (var lineWin in result.PrizeLines)
            {
                lineTemps.Add(lineWin.LineId);
                itemWins.AddRange(lineWin.Position);
            }
            itemWins = itemWins.Distinct().ToList();
            itemWins.AddRange(itemBonus);

            _machine.ShowLineAndItemWin(lineTemps, itemWins);

            if (result.IsJackpot)
            {
                bool isShowing = true;
                UILayerController.Instance.ShowLayer(UILayerKey.LGameSlot25LineWin, _assetBundleConfig.name, (layer) =>
                {
                    ((LGameSlot25LineWin)layer).Init(LGameSlot25LineWin.Slot25LineWinType.JACKPOT, _config, () =>
                    {
                        isShowing = false;
                    }, result.TotalJackpotValue);
                });

                yield return(new WaitUntil(() => !isShowing));

                yield return(new WaitForSeconds(0.5f));
            }
        }
        else
        {
            // ko trung gi
        }

        // free
        if (result.AddFreeSpin > 0)
        {
            if (accountSpin.FreeSpins <= 0)
            {
                bool isShowing = true;
                UILayerController.Instance.ShowLayer(UILayerKey.LGameSlot25LineWin, _assetBundleConfig.name, (layer) =>
                {
                    ((LGameSlot25LineWin)layer).Init(LGameSlot25LineWin.Slot25LineWinType.FREE, _config, () =>
                    {
                        isShowing = false;
                    }, result.AddFreeSpin);
                });

                yield return(new WaitUntil(() => !isShowing));

                yield return(new WaitForSeconds(0.5f));
            }
        }

        if (result.FreeSpins > 0)
        {
            accountSpin.FreeSpins = result.FreeSpins;
        }
        else if (result.AddFreeSpin > 0)
        {
            accountSpin.FreeSpins = result.AddFreeSpin;
        }
        else
        {
            accountSpin.FreeSpins = result.FreeSpins;
        }
        SetNotifyFree();

        // bigwin
        if (!result.IsJackpot)
        {
            int xBet = (int)(result.TotalPrizeValue / (roomBetValue * _machine.idLineSelecteds.Count));
            // bigwin
            if (xBet >= 25)
            {
                bool isShowing = true;
                UILayerController.Instance.ShowLayer(UILayerKey.LGameSlot25LineWin, _assetBundleConfig.name, (layer) =>
                {
                    ((LGameSlot25LineWin)layer).Init(LGameSlot25LineWin.Slot25LineWinType.PERFECT, _config, () =>
                    {
                        isShowing = false;
                    }, result.TotalPrizeValue);
                });

                yield return(new WaitUntil(() => !isShowing));

                yield return(new WaitForSeconds(0.5f));
            }
            else if (xBet >= 10)
            {
                bool isShowing = true;
                UILayerController.Instance.ShowLayer(UILayerKey.LGameSlot25LineWin, _assetBundleConfig.name, (layer) =>
                {
                    ((LGameSlot25LineWin)layer).Init(LGameSlot25LineWin.Slot25LineWinType.BIGWIN, _config, () =>
                    {
                        isShowing = false;
                    }, result.TotalPrizeValue);
                });

                yield return(new WaitUntil(() => !isShowing));

                yield return(new WaitForSeconds(0.5f));
            }
        }

        // bonus
        if (result.IsBonusGame())
        {
            bonusResult = null;

            // show win bonus
            bool isShowing = true;
            UILayerController.Instance.ShowLayer(UILayerKey.LGameSlot25LineWin, _assetBundleConfig.name, (layer) =>
            {
                ((LGameSlot25LineWin)layer).Init(LGameSlot25LineWin.Slot25LineWinType.BONUS, _config, () =>
                {
                    isShowing = false;
                });
            });

            yield return(new WaitUntil(() => !isShowing));

            // show game bonus
            isShowing = true;
            UILayerController.Instance.ShowLayer(UILayerKey.LGameSlot25LineBonus, _assetBundleConfig.name, (layer) =>
            {
                ((LGameSlot25LineBonus)layer).Init(_config, result.BonusGame, roomBetValue, () =>
                {
                    isShowing = false;
                    _server.HubCallFinishBonusGame(moneyType, result.SpinId);
                });
            });

            yield return(new WaitUntil(() => !isShowing));

            yield return(new WaitUntil(() => bonusResult != null));

            yield return(new WaitUntil(() => bonusResult == null));
        }

        // Money
        if (result.TotalPrizeValue > 0)
        {
            AudioAssistant.Instance.PlaySoundGame(_config.gameId, _config.audioWin);
            btLieu.gameObject.SetActive(true);
        }
        SetNotifyMoney(result.TotalPrizeValue > 0 ? VKCommon.ConvertStringMoney(result.TotalPrizeValue) : "");
        vkTxtTotalWin.UpdateNumber(result.TotalPrizeValue);

        //yield return new WaitForSeconds(2f);

        // finish
        waitMachineFinish = null;

        if (isAutoSpin)
        {
            if (result.TotalPrizeValue > 0)
            {
                yield return(new WaitForSeconds(_config.timeWaitNextAuto));
            }
            else
            {
                yield return(new WaitForSeconds(0.2f));
            }

            if (isAutoSpin)
            {
                ButtonSpinClickListener();
            }
        }
        else
        {
            if (!_minigame.isPlaying)
            {
                EnableToPlay();
            }
            StartAnimLastResult();
        }
    }