Exemplo n.º 1
0
    /// <summary>
    /// 即时退奖
    /// </summary>
    /// <remarks>Dat_PlayersScoreWon中值,可以退奖则扣下</remarks>
    /// <returns></returns>
    public IEnumerator _Coro_OutBountyImm()
    {
        if (mIsOutingBounty)
        {
            yield break;
        }

        BackStageSetting bss   = GameMain.Singleton.BSSetting;
        INemoControlIO   arcIO = GameMain.Singleton.ArcIO;

        int oneBountyNeedScore = 100000000;//防止出现bug不会退

        if (bss.OutBountyType_.Val == OutBountyType.OutCoinImmediate)
        {
            oneBountyNeedScore = bss.InsertCoinScoreRatio.Val;
        }
        else if (bss.OutBountyType_.Val == OutBountyType.OutTicketImmediate)
        {
            oneBountyNeedScore = (int)(((float)bss.InsertCoinScoreRatio.Val) * bss.CoinTicketRatio_Coin.Val / bss.CoinTicketRatio_Ticket.Val);//投币比例(分/币) * 币票比(币/票) = 出一票需要多少分(分/票)
        }
        if (bss.Dat_PlayersScoreWon[Idx].Val < oneBountyNeedScore)
        {
            yield break;
        }

        mIsOutingBounty = true;

        //请求硬件扣币
        if (bss.OutBountyType_.Val == OutBountyType.OutCoinImmediate)
        {
            arcIO.OutCoin(1, CtrllerIdx);
        }
        else if (bss.OutBountyType_.Val == OutBountyType.OutTicketImmediate)
        {
            arcIO.OutTicket(1, CtrllerIdx);
        }


        bool  isBoutyOutted = false; //是否已出奖励
        float timeOut       = 10F;   //超时时间
        float elapse        = 0F;
        NemoCtrlIO_EventController outBountyreflect = (int cIdx) =>
        {
            if (CtrllerIdx == cIdx)
            {
                isBoutyOutted = true;
            }
        };

        if (bss.OutBountyType_.Val == OutBountyType.OutCoinImmediate)
        {
            arcIO.EvtOutCoinReflect += outBountyreflect;
        }
        else if (bss.OutBountyType_.Val == OutBountyType.OutTicketImmediate)
        {
            arcIO.EvtOutTicketReflect += outBountyreflect;
        }


        while (!isBoutyOutted)
        {
            if (elapse > timeOut)// 超时
            {
                //显示退奖错误提示
                if (bss.OutBountyType_.Val == OutBountyType.OutCoinImmediate)
                {
                    mGOViewingOutBountyHint = Instantiate(Prefab_OutBountyHints[2]) as GameObject;
                }
                else if (bss.OutBountyType_.Val == OutBountyType.OutTicketImmediate)
                {
                    mGOViewingOutBountyHint = Instantiate(Prefab_OutBountyHints[3]) as GameObject;
                }
                mGOViewingOutBountyHint.transform.parent        = transform;
                mGOViewingOutBountyHint.transform.localPosition = LocalOutBountyHint;
                mGOViewingOutBountyHint.transform.localRotation = Quaternion.identity;

                yield return(new WaitForSeconds(30F));

                mIsOutingBounty = false;
                StartCoroutine(_Coro_OutBountyImm());
                yield break;
            }
            elapse += Time.deltaTime;
            yield return(0);
        }

        //出币已应答
        if (bss.OutBountyType_.Val == OutBountyType.OutCoinImmediate)
        {
            arcIO.EvtOutCoinReflect -= outBountyreflect;
        }
        else if (bss.OutBountyType_.Val == OutBountyType.OutTicketImmediate)
        {
            arcIO.EvtOutTicketReflect -= outBountyreflect;
        }



        //历史记录
        if (bss.OutBountyType_.Val == OutBountyType.OutCoinImmediate)
        {
            bss.His_CoinOut.Val     += 1;
            bss.His_GainCurrent.Val -= 1;
            bss.UpdateGainCurrentAndTotal();
        }
        else if (bss.OutBountyType_.Val == OutBountyType.OutTicketImmediate)
        {
            bss.His_TicketOut.Val += 1;

            //所有玩家公用
            bss.TicketOutFragment.Val += 1;
            int outCoinNumBase = bss.TicketOutFragment.Val / bss.CoinTicketRatio_Ticket.Val;//出币基数,乘与CoinTicketRatio_Coin 得出应出多少个整币
            if (outCoinNumBase > 0)
            {
                bss.His_GainCurrent.Val   -= outCoinNumBase * bss.CoinTicketRatio_Coin.Val;
                bss.TicketOutFragment.Val -= bss.CoinTicketRatio_Ticket.Val;
            }
            bss.UpdateGainCurrentAndTotal();
        }
        if (bss.Dat_PlayersScoreWon[Idx].Val < oneBountyNeedScore)
        {
            Debug.LogError("[退奖错误]该扣分数大于玩家已赢分数.");
            yield break;
        }

        bss.Dat_PlayersScoreWon[Idx].Val = bss.Dat_PlayersScoreWon[Idx].Val - oneBountyNeedScore;
        if (GameMain.EvtPlayerWonScoreChanged != null)
        {
            GameMain.EvtPlayerWonScoreChanged(this, bss.Dat_PlayersScoreWon[Idx].Val);
        }
        //Ef_CoinStack.OneStack_SetNum(bss.Dat_PlayersScoreWon[Idx].Val);
        mIsOutingBounty = false;

        //是否可再扣分,可以则迭代
        if (bss.Dat_PlayersScoreWon[Idx].Val >= oneBountyNeedScore)
        {
            StartCoroutine(_Coro_OutBountyImm());
        }

        if (mGOViewingOutBountyHint != null)
        {
            Destroy(mGOViewingOutBountyHint);
            mGOViewingOutBountyHint = null;
        }
    }
Exemplo n.º 2
0
    /// <summary>
    /// 按键退币-协同
    /// </summary>
    /// <returns></returns>
    public IEnumerator _Coro_OutBountyButtom()
    {
        if (mIsOutingBounty)
        {
            yield break;
        }

        BackStageSetting bss   = GameMain.Singleton.BSSetting;
        INemoControlIO   arcIO = GameMain.Singleton.ArcIO;
        int oneBountyNeedScore = 100000000;//不会退

        if (bss.OutBountyType_.Val == OutBountyType.OutCoinButtom)
        {
            oneBountyNeedScore = bss.InsertCoinScoreRatio.Val;
        }
        else if (bss.OutBountyType_.Val == OutBountyType.OutTicketButtom)
        {
            oneBountyNeedScore = (int)(((float)bss.InsertCoinScoreRatio.Val) * bss.CoinTicketRatio_Coin.Val / bss.CoinTicketRatio_Ticket.Val);  //投币比例(分/币) * 币票比(币/票) = 出一票需要多少分(分/票)
        }
        //检查是否够退一币
        if (bss.Dat_PlayersScore[Idx].Val < oneBountyNeedScore)
        {
            yield break;
        }

        //显示退奖中提示
        if (mGOViewingOutBountyHint == null)
        {
            if (bss.OutBountyType_.Val == OutBountyType.OutCoinButtom)
            {
                mGOViewingOutBountyHint = Instantiate(Prefab_OutBountyHints[0]) as GameObject;
            }
            else if (bss.OutBountyType_.Val == OutBountyType.OutTicketButtom)
            {
                mGOViewingOutBountyHint = Instantiate(Prefab_OutBountyHints[1]) as GameObject;
            }
            mGOViewingOutBountyHint.transform.parent        = transform;
            mGOViewingOutBountyHint.transform.localPosition = LocalOutBountyHint;
            mGOViewingOutBountyHint.transform.localRotation = Quaternion.identity;
        }



        mScoreChangeLowest = (uint)oneBountyNeedScore;//设置分数改变下限,防止控制板返回消息时不能扣除
        mIsOutingBounty    = true;

        if (bss.OutBountyType_.Val == OutBountyType.OutCoinButtom)
        {
            arcIO.OutCoin(1, CtrllerIdx);
        }
        else if (bss.OutBountyType_.Val == OutBountyType.OutTicketButtom)
        {
            arcIO.OutTicket(1, CtrllerIdx);
        }

        bool  isBoutyOutted = false; //是否已出奖励
        float timeOut       = 10F;   //超时时间
        float elapse        = 0F;
        NemoCtrlIO_EventController outBountyreflect = (int cIdx) =>
        {
            if (CtrllerIdx == cIdx)
            {
                isBoutyOutted = true;
            }
        };

        if (bss.OutBountyType_.Val == OutBountyType.OutCoinButtom)
        {
            arcIO.EvtOutCoinReflect += outBountyreflect;
        }
        else if (bss.OutBountyType_.Val == OutBountyType.OutTicketButtom)
        {
            arcIO.EvtOutTicketReflect += outBountyreflect;
        }
        while (!isBoutyOutted)
        {
            if (elapse > timeOut)
            {
                StartCoroutine(_Coro_OutBountyErrorView()); //显示故障
                mIsOutingBounty    = false;
                mScoreChangeLowest = 0;                     //恢复改变分数下限
                yield break;
            }
            elapse += Time.deltaTime;
            yield return(0);
        }

        //出币已应答
        if (bss.OutBountyType_.Val == OutBountyType.OutCoinButtom)
        {
            arcIO.EvtOutCoinReflect -= outBountyreflect;
        }
        else if (bss.OutBountyType_.Val == OutBountyType.OutTicketButtom)
        {
            arcIO.EvtOutTicketReflect -= outBountyreflect;
        }
        mIsOutingBounty    = false;
        mScoreChangeLowest = 0;//恢复改变分数下限

        //历史记录
        if (bss.OutBountyType_.Val == OutBountyType.OutCoinButtom)
        {
            bss.His_CoinOut.Val     += 1;
            bss.His_GainCurrent.Val -= 1;
            bss.UpdateGainCurrentAndTotal();
        }
        else if (bss.OutBountyType_.Val == OutBountyType.OutTicketButtom)
        {
            bss.His_TicketOut.Val += 1;

            //所有玩家公用
            bss.TicketOutFragment.Val += 1;
            int outCoinNumBase = bss.TicketOutFragment.Val / bss.CoinTicketRatio_Ticket.Val;//出币基数,乘与CoinTicketRatio_Coin 得出应出多少个整币
            if (outCoinNumBase > 0)
            {
                bss.His_GainCurrent.Val   -= outCoinNumBase * bss.CoinTicketRatio_Coin.Val;
                bss.TicketOutFragment.Val -= bss.CoinTicketRatio_Ticket.Val;
            }
            bss.UpdateGainCurrentAndTotal();
        }

        ChangeScore(-oneBountyNeedScore);

        //是否可再扣分,可以则迭代
        if (bss.Dat_PlayersScore[Idx].Val >= oneBountyNeedScore)
        {
            StartCoroutine(_Coro_OutBountyButtom());
        }
        else//退出迭代
        {
            if (mGOViewingOutBountyHint != null)
            {
                Destroy(mGOViewingOutBountyHint);
                mGOViewingOutBountyHint = null;
            }
        }
    }