예제 #1
0
        /// <summary>
        /// 初始化 房间
        /// </summary>
        public void InitRoom(ISFSObject gameInfo)
        {
            var gdata = App.GetGameData <SssGameData>();

            if (gameInfo.ContainsKey("showGoldRate"))
            {
                gdata.ShowGoldRate = gameInfo.GetInt("showGoldRate");
            }

            if (gameInfo.ContainsKey("rule"))
            {
                RoomRuleView.InitRoomRuleInfo(gameInfo);
            }

            if (gameInfo.ContainsKey("ownerId"))
            {
                _ownerId = gameInfo.GetInt("ownerId");
            }

            RoomInfo.ShowRoomInfo(gameInfo);
            //获取房间配置
            if (gdata.IsRoomGame)
            {
                WeiXinInviteBtn.ChatInviteBtn.SetActive(!gdata.IsPlayed);
                HistoryMgr.MaxCount = gameInfo.GetInt("maxRound");
            }
            else
            {
                WeiXinInviteBtn.ChatInviteBtn.SetActive(false);
            }

            if (gameInfo.ContainsKey("state"))
            {
                int state = gameInfo.GetInt("state");
                if (state > 1)
                {
                    int cd            = gameInfo.GetInt("cd");
                    int remainingTime = GetRemainingTime(cd, gameInfo);
                    ClockCd.BeginCountDown(remainingTime, (int)gameInfo.GetLong("st"), false);     //开始记时
                    Debug.Log("<color=#00FF2BFF>" + "重连服务器时间擢" + gameInfo.GetLong("ct") + "</color>");
                    YxClockManager.BeginToCountDown(remainingTime);
                }
            }

            if (ChoiseWay != null)
            {
                int len = ChoiseWay.Length;
                for (int i = 0; i < len; i++)
                {
                    ChoiseWay[i].Init();
                }
            }
        }
예제 #2
0
        internal void OnBet(ISFSObject data)
        {
            int bankerSeat = data.GetInt("banker");
            var gdata      = App.GetGameData <PaiJiuGameData>();

            gdata.BankerSeat = bankerSeat;
            gdata.GetPlayer <PaiJiuPlayer>(bankerSeat, true).SetBankerMarkActive(true);
            if (bankerSeat != App.GameData.SelfSeat)
            {
                SpeakMgr.ShowSpeak(GameRequestType.BeginBet);
            }

            CheckShowedPanel.ResetCards(data.GetInt("cardcnt") > 16);       //一次出现发牌16张,共32张牌.如果张数为32,就需要重置出现牌信息
            YxClockManager.BeginToCountDown(data.GetInt("cd"));
            TableData.SetTalebData(data);
            OnGameStart();
        }
예제 #3
0
        public void InitGameInfo(ISFSObject gameInfo)
        {
            var gdata = App.GetGameData <PaiJiuGameData>();

            if (gameInfo.ContainsKey("curante"))
            {
                gdata.Ante = gameInfo.GetInt("curante");
            }
            if (gameInfo.ContainsKey("cargs2"))
            {
                BetMgr.InitChips(gameInfo);
            }
            if (gameInfo.ContainsKey("banker"))
            {
                gdata.BankerSeat = gameInfo.GetInt("banker");
            }



            var status = 0;

            if (gameInfo.ContainsKey("status"))
            {
                status       = gameInfo.GetInt("status");
                gdata.Status = status;
                bool isGameing = status > 0;
                gdata.IsGameing = isGameing;
                //设置时间
                if (!isGameing || !gameInfo.ContainsKey("cd"))
                {
                    return;
                }
                var cd = gameInfo.GetInt("cd");
                cd -= (int)(gameInfo.GetLong("ct") - gameInfo.GetLong("st"));
                YxClockManager.BeginToCountDown(cd);
            }
        }
예제 #4
0
        public override void GameResponseStatus(int type, ISFSObject response)
        {
            YxDebug.Log("Request == " + (GameRequestType)type);

            var gdata = App.GetGameData <PaiJiuGameData>();

            gdata.Status = type;

            switch ((GameRequestType)type)
            {
            case GameRequestType.AllowStart:
                gdata.GetPlayer <PaiJiuPlayerSelf>().CouldStart();
                break;

            case GameRequestType.BeginBet:
                OnBet(response);
                break;

            case GameRequestType.UserBet:
                int betSeat = response.GetInt("seat");
                gdata.GetPlayer <PaiJiuPlayer>(betSeat, true).PlayerBet(response.GetInt("gold"));
                break;

            case GameRequestType.SendCard:
                TableData.SubCardCount(16);
                SpeakMgr.ShowNothing();
                YxClockManager.BeginToCountDown(response.GetInt("cd"));
                DealerMgr.BeginBigDeal(response.GetIntArray("card"));
                Tool.Tools.TestDebug(response.GetIntArray("card"));
                //SpeakMgr.ShowSpeak(GameRequestType.SendCard);
                break;

            case GameRequestType.PutCard:
                DealerMgr.FastDeal();
                int putcardSeat = response.GetInt("seat");
                gdata.GetPlayer <PaiJiuPlayer>(putcardSeat, true).FinishSelect();
                if (putcardSeat == App.GameData.SelfSeat)
                {
                    if (response.ContainsKey("cards"))
                    {
                        int[] putCards = new int[4];            //data.GetIntArray("cards");
                        gdata.GetPlayer <PaiJiuPlayer>(putcardSeat, true).UserBetPoker.SetBetPokerInfo(putCards);
                    }
                    SpeakMgr.ShowNothing();
                }
                break;

            case GameRequestType.Compare:
                OnCompare(response);
                break;

            case GameRequestType.AllowReady:
                gdata.IsGameing = false;
                Reset();
                ReadyList.Clear();
                break;

            case GameRequestType.GameBegin:
                break;
            }
        }
예제 #5
0
        public override void GameResponseStatus(int type, ISFSObject data)
        {
            var gdata = App.GetGameData <BlackJackGameData>();

            if (!gdata.IsGameInfo)
            {
                YxDebug.LogError("GameInfo还没有初始化!!");
                return;
            }

            switch ((GameRequestType)type)
            {
            case GameRequestType.StartAnte:

                DealPokerMgr.CleanPokers();            //清理掉上一把没有清理掉的手牌
                //ClockCd.BeginCountDown(data.GetInt("cd"));
                YxClockManager.BeginToCountDown(data.GetInt("cd"));
                SpeakMgr.BetViewActive(true);

                //游戏开始,隐藏准备按键和标志
                var anteUsers = gdata.PlayerList;
                foreach (var yxBaseGamePlayer in anteUsers)
                {
                    var anteUser = (BjPlayerPanel)yxBaseGamePlayer;
                    anteUser.SetReadyBtnActive(false);
                    anteUser.SetReadyMarkActive(false);
                }
                break;


            case GameRequestType.EndAnte:

                SpeakMgr.ShowNothing();
                YxClockManager.StopToCountDown();
                break;


            case GameRequestType.Ante:

                int anteSeat = data.GetInt("seat");
                int anteGold = data.GetInt("gold");
                gdata.GetPlayer <BjPlayerPanel>(anteSeat, true).PlayerBet(anteGold);
                if (anteSeat == SelfSeat && anteGold > 0)
                {
                    gdata.IsPlaying = true;
                    BetBtnMgr.CheckColdClickAnte();
                }
                break;


            case GameRequestType.Allocate:

                if (data.ContainsKey("cards"))
                {
                    ISFSArray allocateArray = data.GetSFSArray("cards");

                    foreach (ISFSObject player in allocateArray)
                    {
                        int[] allocateSeat   = { player.GetInt("seat") };
                        int[] allowcateCards = player.GetIntArray("cards");
                        DealPokerMgr.EnqueueCardInfo(allocateSeat, allowcateCards);
                        DealPokerMgr.BeginDealCards();          //开始发牌
                    }
                }

                if (data.ContainsKey("bankcards"))
                {
                    int[] albankerCards = data.GetIntArray("bankcards");

                    DealPokerMgr.EnqueueCardInfo(gdata.BjBankerBanker, albankerCards);
                    DealPokerMgr.BeginDealCards();
                }

                if (data.ContainsKey("card"))
                {
                    int cardSeat = data.GetInt("seat");
                    DealPokerMgr.EnqueueCardInfo(cardSeat, data.GetInt("card"));
                    gdata.GetPlayer <BjPlayerPanel>(cardSeat, true).StopCountDown();

                    if (gdata.IsMyTurn(cardSeat))
                    {
                        SpeakMgr.DoubleBtnEnable(false);
                        SpeakMgr.InsuranceBtnEnable(false);
                    }
                }
                SpeakMgr.ShowNothing();
                break;


            case GameRequestType.Result:
                gdata.IsGameing = false;
                gdata.IsPlaying = false;
                ResultMgr.InitResultView(data);
                ResultMgr.ShowResultView();

                if (data.ContainsKey("users"))
                {
                    ISFSArray resultUsers = data.GetSFSArray("users");
                    foreach (ISFSObject resultUser in resultUsers)
                    {
                        int resultSeat = resultUser.GetInt("seat");
                        var panel      = gdata.GetPlayer <BjPlayerPanel>(resultSeat, true);
                        if (panel.Info == null)
                        {
                            continue;
                        }
                        panel.Coin = resultUser.GetLong("ttgold");

                        if (resultSeat == SelfSeat)
                        {
                            ResultMgr.InitResultView(resultUser);
                        }
                    }
                }
                Invoke("ResetGame", 6);
                break;


            case GameRequestType.Speak:

                int   speakSeat = data.GetInt("seat");
                float speakCd   = data.GetInt("cd");
                gdata.GetPlayer <BjPlayerPanel>(speakSeat, true).BeginCountDown(speakCd);

                if (speakSeat != SelfSeat)
                {
                    YxDebug.Log(" === no my self === " + SelfSeat);
                    SpeakMgr.ShowNothing();
                    break;
                }

                SpeakMgr spkMgr = SpeakMgr;
                spkMgr.SpeakViewActive(true);

                //显示双倍和保险按键
                if (data.ContainsKey("addrate"))
                {
                    //双倍按钮的显示和是否能按
                    spkMgr.DoubleBtn.SetActive(data.GetBool("addrate"));
                    spkMgr.DoubleBtnEnable(SelfPlayer.BetMoney / 2 <= gdata.GetSelfPanel().Coin);

                    //保险按钮的显示和是否能按
                    spkMgr.InsuranceBtn.SetActive(data.GetBool("insurance"));
                    spkMgr.InsuranceBtnEnable(SelfPlayer.BetMoney <= gdata.GetSelfPanel().Coin);
                }

                break;


            case GameRequestType.Stand:

                int standSeat = data.GetInt("seat");
                gdata.GetPlayer <BjPlayerPanel>(standSeat).StopCountDown();
                if (standSeat == SelfSeat)
                {
                    SpeakMgr.ShowNothing();
                }

                break;


            case GameRequestType.AddRate:

                if (data.ContainsKey("seat"))
                {
                    int addRateSeat = data.GetInt("seat");
                    gdata.GetPlayer <BjPlayerPanel>(addRateSeat).BuyDouble(data.GetInt("gold"));
                    if (addRateSeat == SelfSeat)
                    {
                        SpeakMgr.SpeakViewActive(true);
                        SpeakMgr.DoubleBtnEnable(false);
                    }
                }
                break;

            case GameRequestType.BankerAllocate:

                SpeakMgr.ShowNothing();

                if (data.ContainsKey("cards"))
                {
                    gdata.BjBankerBanker.ShowBankerCard0(data.GetIntArray("cards")[0]);
                    DealPokerMgr.DealAllPoker();
                }

                //庄家要牌
                if (data.ContainsKey("card"))
                {
                    DealPokerMgr.EnqueueCardInfo(gdata.BjBankerBanker, data.GetInt("card"));
                    DealPokerMgr.BeginDealCards();
                }

                break;

            case GameRequestType.Insurance:

                if (data.ContainsKey("seat"))
                {
                    int insuranceSeat = data.GetInt("seat");
                    gdata.GetPlayer <BjPlayerPanel>(insuranceSeat).BuyInsurance(data.GetInt("gold"));

                    if (insuranceSeat == SelfSeat)
                    {
                        SpeakMgr.SpeakViewActive(true);
                        SpeakMgr.InsuranceBtnEnable(false);
                    }
                }

                break;
            }
        }