Esempio n. 1
0
        /// <summary>
        /// 初始化 房间
        /// </summary>
        public void InitRoom(ISFSObject gameInfo)
        {
            if (gameInfo.ContainsKey("rid") && RModelMgr != null)
            {
                RModelMgr.ShowRoomInfo(gameInfo);
            }
            var gdata = App.GetGameData <GangwuGameData>();

            if (gdata.IsGameStart)
            {
                //当前谁说话
                if (gameInfo.ContainsKey("current"))
                {
                    App.GetGameManager <GangWuGameManager>().Speaker(gameInfo.GetInt("current"));
                }

                //下过的筹码 除当前轮
                int allBetV = 0;

                foreach (ISFSObject user in gameInfo.GetSFSArray("users"))
                {
                    PlayerPanel player = gdata.GetPlayer <PlayerPanel>(user.GetInt("seat"), true);
                    int         xz     = user.GetInt("ttxz") - user.GetInt("rndGold");

                    allBetV += xz;
                    if (user.GetLong("ttgold") <= 0 && player.ReadyState)
                    {
                        player.CurGameType = PlayerGameType.AllIn;
                    }

                    //服务器给的的棋牌
                    if (user.GetInt("txstate") == 2)
                    {
                        player.CurGameType = PlayerGameType.Fold;
                    }
                    player.PlayerBet(user.GetInt("rndGold"), false);
                }
                //下过筹码才有收
                if (allBetV > 0)
                {
                    BetMgr.CollectBetValue();
                }

                if (gameInfo.ContainsKey("opData"))
                {
                    var sfs  = gameInfo.GetSFSObject("opData");
                    var type = sfs.GetInt(RequestKey.KeyType);
                    App.GetGameManager <GangWuGameManager>().GameResponseStatus(type, sfs);
                }
            }

            BetMgr.SetChipsTime();      //设置筹码倍数
        }
Esempio n. 2
0
        public override void GameResponseStatus(int type, ISFSObject response)
        {
            var gdata = App.GetGameData <GangwuGameData>();

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

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

                if (response.ContainsKey("seat"))
                {
                    int         bseat    = response.GetInt("seat");
                    int         bgold    = response.GetInt("gold");
                    PlayerPanel onePanel = gdata.GetPlayer <PlayerPanel>(bseat, true);
                    if (bgold > 0)
                    {
                        if (bgold + onePanel.BetMoney == SpeakMgr.MaxBetNum)
                        {
                            onePanel.ShowGameType("call");
                        }
                        else if (onePanel.Info != null && bgold == onePanel.Coin)
                        {
                            onePanel.CurGameType = PlayerGameType.AllIn;
                            onePanel.ShowGameType("allIn");
                        }
                        else
                        {
                            onePanel.ShowGameType("");
                        }
                    }
                    else
                    {
                        onePanel.ShowGameType("seePoker");
                    }
                    onePanel.PlayerBet(bgold);

                    if (onePanel.CurGameType != PlayerGameType.AllIn &&
                        onePanel.BetMoney > SpeakMgr.MaxBetNum)
                    {
                        Facade.Instance <MusicManager>().Play("addBet");
                        onePanel.ShowGameType(string.Empty);
                    }
                    else if (onePanel.CurGameType != PlayerGameType.AllIn &&
                             onePanel.BetMoney == SpeakMgr.MaxBetNum)
                    {
                        Facade.Instance <MusicManager>().Play(bgold > 0
                                ? "call"
                                : "seePoker");
                    }

                    //设置最大下注
                    SpeakMgr.MaxBetNum = onePanel.BetMoney >
                                         SpeakMgr.MaxBetNum
                            ? onePanel.BetMoney
                            : SpeakMgr.MaxBetNum;


                    if (bseat == gdata.SelfSeat)
                    {
                        SpeakMgr.ShowAuto();
                        SpeakMgr.AddBetSum = 0;
                    }
                }
                //包含users说明游戏开始
                else if (response.ContainsKey("users"))
                {
                    ++gdata.CurRound;
                    int[] beginSeats   = response.GetIntArray("users");
                    int   beginBetGold = response.GetInt("guoBet");
                    gdata.Ante        = response.GetInt("curante");
                    gdata.IsGameStart = true;
                    gdata.IsPlayed    = true;
                    foreach (int seat in beginSeats)
                    {
                        PlayerPanel panel = gdata.GetPlayer <PlayerPanel>(seat, true);
                        if (panel.Info != null)
                        {
                            panel.SetPlayerReadyState(true);
                            panel.PlayerBet(beginBetGold);
                        }
                    }
                    HistoryResultMgr.CreateHistoryItem(beginSeats);
                    //隐藏准备按钮
                    gdata.GetPlayer <SelfPlayerPanel>().OnGameStart();
                }
                break;



            case GameRequestType.Fold:
                int         fseat     = response.GetInt("seat");
                PlayerPanel foldPanel = gdata.GetPlayer <PlayerPanel>(fseat, true);
                foldPanel.CurGameType = PlayerGameType.Fold;
                foldPanel.Mask.SetActive(true);
                foldPanel.BetLabel.gameObject.SetActive(foldPanel.BetMoney > 0);
                foldPanel.ShowGameType("fold");
                if (fseat == gdata.SelfSeat)
                {
                    SpeakMgr.ShowNothing();
                }
                break;


            case GameRequestType.Card:

                if (response.ContainsKey("selfCard"))
                {
                    int[] selfCards = response.GetIntArray("selfCard");
                    if (selfCards.Length > 0)
                    {
                        gdata.GetPlayer <PlayerPanel>().UserBetPoker.LeftCardValue = selfCards[0];
                    }
                }

                if (response.ContainsKey("cards"))
                {
                    int[] cardSeats = response.GetIntArray("seats");
                    int[] cards     = response.GetIntArray("cards");

                    int cardCount = response.GetInt("cardCount");
                    gdata.CardCount = cardCount;

                    //如果为cardCount是2,则是第一轮发牌,需要先发一轮暗牌
                    if (cardCount <= 2)
                    {
                        int[] tempCards = new int[cardSeats.Length];

                        for (int i = 0; i < cardSeats.Length; i++)
                        {
                            if (cardSeats[i] == gdata.SelfSeat)
                            {
                                tempCards[i] = gdata.GetPlayer <PlayerPanel>().UserBetPoker.LeftCardValue;
                            }
                        }

                        DealerMgr.BeginBigDeal(tempCards, cardSeats, 0);
                    }

                    DealerMgr.BeginBigDeal(cards, cardSeats, cardCount - 1);

                    //初始化玩家当前状态信息
                    foreach (int seat in cardSeats)
                    {
                        gdata.GetPlayer <PlayerPanel>(seat, true).ShowGameType(string.Empty);
                    }
                }

                //每轮开始清除最大下注
                SpeakMgr.MaxBetNum = 0;
                SpeakMgr.AddBetSum = 0;
                BetMgr.CollectBet();
                foreach (var yxBaseGamePlayer in gdata.PlayerList)
                {
                    var panel = (PlayerPanel)yxBaseGamePlayer;
                    panel.BetMoney      = 0;
                    panel.BetLabel.text = panel.BetMoney.ToString();
                }

                SpeakMgr.BetRemenber.Clear();

                break;


            case GameRequestType.Result:
                gdata.AllocateFour = false;
                //当接到结算时,由于要排除由于手机卡顿或者由于有玩家手上筹码过少,引起的直接结算,这里将手牌取消动画显示
                DealerMgr.OnResult();

                ResultMgr.OnGameResult(response.GetSFSArray("result"));
                StartCoroutine(ShowResultView());

                DoResult(response);

                HistoryResultMgr.GetHistoryInfo(response);

                YxClockManager.StopWaitPlayer();
                break;


            case GameRequestType.BetSpeak:

                int betSpeakSeat = response.GetInt("seat");
                var betSpeaker   = gdata.GetPlayer <PlayerPanel>(betSpeakSeat, true);

                if (!betSpeaker.ReadyState)
                {
                    return;
                }

                gdata.AllocateFour = response.ContainsKey("allocateFour") && response.GetBool("allocateFour");

                gdata.SpeakCd = response.GetInt("cd");
                betSpeaker.ShowGameType(string.Empty);
                Speaker(betSpeakSeat, response.GetInt("cd"));
                if (betSpeakSeat == gdata.SelfSeat)
                {
                    betSpeaker.BetLabel.gameObject.SetActive(true);
                    SpeakMgr.ShowSpeak();
                }
                break;



            case GameRequestType.FollowSpeak:

                int followSpeakSeat = response.GetInt("seat");
                var followSpeaker   = gdata.GetPlayer <PlayerPanel>(followSpeakSeat, true);
                if (!followSpeaker.ReadyState)
                {
                    return;
                }

                gdata.SpeakCd      = response.GetInt("cd");
                gdata.AllocateFour = response.GetBool("allocateFour");
                followSpeaker.ShowGameType(string.Empty);

                Speaker(followSpeakSeat, response.GetInt("cd"));
                if (followSpeakSeat == gdata.SelfSeat)
                {
                    followSpeaker.BetLabel.gameObject.SetActive(true);
                    SpeakMgr.ShowSpeak();
                }
                break;

            case GameRequestType.AllowReady:
                gdata.AllocateFour = false;
                gdata.IsGameStart  = false;

                _waitResult = false;       //允许显示结算

                YxClockManager.StopWaitPlayer();
                break;

            default:
                YxDebug.Log("不存在的服务器交互!");
                break;
            }
        }