Exemplo n.º 1
0
    public void InitSeatResult(RepeatedField <Msg.SeatResult> ResultList)
    {
        for (int i = 0; i < ResultList.Count; i++)
        {
            Msg.SeatResult result = ResultList [i];

            CSeatResult info = new CSeatResult();

            info.SeatID = (int)result.SeatId;

            for (int o = 0; o < result.CardGroups.Count; o++)
            {
                Msg.CardGroup cg = result.CardGroups[o];
                info.Pres.Add(cg.Cards);
            }

            if ((int)result.SeatId != 0)
            {
                info.score = new List <int> (result.Scores);
            }

            foreach (PlayerInfo p in Common.CPlayers)
            {
                if (p.SeatID == info.SeatID)
                {
                    info.Name   = p.Name;
                    info.Avatar = p.FB_avatar;
                    info.BWin   = p.Score;
                }
            }

            info.autowin = result.Autowin;
            info.foul    = result.Foul;
            info.Win     = result.Win;
            info.Ranks   = result.Ranks;

            Common.CSeatResults.Add(info.SeatID, info);
        }
    }
Exemplo n.º 2
0
    public void Data(Protocol data)
    {
        Loom.QueueOnMainThread(() => {
            Common.Sumbiting = false;
            Common.EndCalling();
        });


        //Debug.Log (data.ToString());
        if (data == null)
        {
            return;
        }

        switch (data.Msgid)
        {
        case MessageID.LeaveRoomRsp:
            if (data.LeaveRoomRsp.Ret == 0)
            {
                Loom.QueueOnMainThread(() => {
                    ExitGame();
                });
            }
            else
            {
                Loom.QueueOnMainThread(() => {
                    Common.TipsOn(PrefabTips, Canvas.gameObject, Common.TipsCantLeave);
                });
            }
            break;

        case MessageID.AutoBankerRsp:
            if (data.AutoBankerRsp.Ret == 0)
            {
            }
            break;

        case MessageID.SitDownRsp:
            if (data.SitDownRsp.Ret == 0)
            {
                Loom.QueueOnMainThread(() => {
                    SetSeatID(Common.Uid, m_TatgetSeatID);
                    UpdateOrderList();

                    if (m_TatgetSeatID == 0)
                    {
                        if (GetTablePlayersCount() > 1 && Common.CState == Msg.GameState.Ready)
                        {
                            m_Letplay.SetActive(true);
                        }
                        Common.CAutoBanker = data.SitDownRsp.Autobanker;
                    }

                    if (m_StateManage.GetCulState() == STATE.STATE_BETTING)
                    {
                        m_StateManage.m_StateBetting.SitDown();
                    }
                });
            }
            else if (data.SitDownRsp.Ret == ErrorID.SitDownCreditPointsOut)
            {
                Loom.QueueOnMainThread(() => {
                    Common.TipsOn(PrefabTips, Canvas.gameObject, Common.TipsCreditMax);
                });
            }
            else
            {
                Loom.QueueOnMainThread(() => {
                    Common.TipsOn(PrefabTips, Canvas.gameObject, Common.TipsSeatWasToken);
                });
            }
            break;

        case MessageID.StandUpRsp:
            if (data.StandUpRsp.Ret == 0)
            {
                Loom.QueueOnMainThread(() => {
                    m_StateManage.m_StateBetting.CancelBet();
                    SetSeatID(Common.Uid, -1);
                    UpdateOrderList();
                    m_Letplay.SetActive(false);
                });
            }
            else
            {
                Loom.QueueOnMainThread(() => {
                    Common.TipsOn(PrefabTips, Canvas.gameObject, Common.TipsCantStandUp);
                });
            }
            break;

        case MessageID.StartGameRsp:
            if (data.StartGameRsp.Ret == ErrorID.StartGameNotEnoughDiamonds)
            {
                Loom.QueueOnMainThread(() => {
                    string names = "";
                    for (int i = 0; i < data.StartGameRsp.NomoneyUids.Count; i++)
                    {
                        PlayerInfo p = GetPlayerIDForUID(data.StartGameRsp.NomoneyUids[i]);

                        if (p != null)
                        {
                            names += p.Name;

                            if ((data.StartGameRsp.NomoneyUids.Count - (i + 1)) >= 2)
                            {
                                names += ",";
                            }
                            else if ((data.StartGameRsp.NomoneyUids.Count - (i + 1)) == 1)
                            {
                                names += " and ";
                            }
                        }
                    }

                    string str = "Insufficient diamond for " + names + " to resume the game";
                    Common.ErrorDialog(PrefabDialog, Canvas.gameObject, str);
                });
            }
            break;

        case MessageID.BetRsp:
            if (data.BetRsp.Ret == 0)
            {
                Loom.QueueOnMainThread(() => {
                    m_StateManage.m_StateBetting.UpdatePlayerBet();
                    m_StateManage.m_StateBetting.DCanBetCall();
                });
            }
            break;

        case MessageID.CombineRsp:
            if (data.CombineRsp.Ret == 0)
            {
                Loom.QueueOnMainThread(() => {
                    List <List <uint> > cards = new List <List <uint> > ();
                    foreach (Msg.CardGroup cardg in data.CombineRsp.CardGroups)
                    {
                        List <uint> duan = new List <uint> (cardg.Cards);
                        cards.Add(duan);
                    }
                    m_StateManage.m_StateSorting.SynchPoker(cards);
                });
            }

            break;

        case MessageID.GetScoreboardRsp:
            if (data.GetScoreboardRsp.Ret == 0)
            {
                Loom.QueueOnMainThread(() => {
                    List <Msg.ScoreboardItem> list = new List <ScoreboardItem>();
                    foreach (Msg.ScoreboardItem t in data.GetScoreboardRsp.Items)
                    {
                        list.Add(t);
                    }
                    m_GameConsole.ShowPlayerList(list, m_PlayerListMode);
                });
            }
            break;

        case MessageID.CloseResultRsp:
            if (data.CloseResultRsp.Ret == 0)
            {
                Loom.QueueOnMainThread(() => {
                });
            }
            break;

        case MessageID.GetRoundHistoryRsp:
            if (data.GetRoundHistoryRsp.Ret == 0)
            {
                Loom.QueueOnMainThread(() => {
                    if (data.GetRoundHistoryRsp.Results.Count <= 0)
                    {
                        return;
                    }

                    Dictionary <int, CSeatResult> LSeatResults = new Dictionary <int, CSeatResult>();

                    for (int i = 0; i < data.GetRoundHistoryRsp.Results.Count; i++)
                    {
                        Msg.PlayerRoundHistory ps = data.GetRoundHistoryRsp.Results[i];

                        CSeatResult info = new CSeatResult();
                        info.SeatID      = (int)ps.Result.SeatId;
                        info.Name        = ps.Name;
                        info.Avatar      = ps.Avatar;
                        info.autowin     = ps.Result.Autowin;
                        info.foul        = ps.Result.Foul;
                        info.Win         = ps.Result.Win;
                        info.Ranks       = ps.Result.Ranks;

                        for (int o = 0; o < ps.Result.CardGroups.Count; o++)
                        {
                            Msg.CardGroup cg = ps.Result.CardGroups[o];
                            info.Pres.Add(cg.Cards);
                        }
                        LSeatResults.Add(info.SeatID, info);
                    }

                    m_GameConsole.ShowHandReview(LSeatResults);
                });
            }
            break;

        case MessageID.GameStateNotify:
            Common.CState = data.GameStateNotify.State;
            switch (data.GameStateNotify.State)
            {
            case Msg.GameState.Ready:
                Loom.QueueOnMainThread(() => {
                    Common.CPlayed_hands = data.GameStateNotify.PlayedHands;
                    m_StateManage.ChangeState(STATE.STATE_SEAT);
                    if (m_SelfSeatID == 0 && GetTablePlayersCount() > 1)
                    {
                        m_Letplay.SetActive(true);
                    }
                });
                break;

            case Msg.GameState.Bet:
                Loom.QueueOnMainThread(() => {
                    Common.CSeatResults.Clear();
                    Common.CPlayed_hands = data.GameStateNotify.PlayedHands;
                    m_Letplay.SetActive(false);
                    Common.ConfigBetTime = (int)data.GameStateNotify.Countdown / 1000;
                    m_StateManage.ChangeState(STATE.STATE_BETTING);
                    m_StateManage.m_StateBetting.AdjustUIChipControl();
                });
                break;

            case Msg.GameState.ConfirmBet:
                Loom.QueueOnMainThread(() => {
                    m_StateManage.m_StateBetting.ShowConfimBet();
                });
                break;

            case Msg.GameState.Deal:
                Loom.QueueOnMainThread(() => {
                    DealCardsEvent(data.GameStateNotify.DealCards);
                    DealSeatEvent(data.GameStateNotify.DealSeats);
                    m_StateManage.ChangeState(STATE.STATE_DEAL);
                });
                break;

            case Msg.GameState.Combine:
                Loom.QueueOnMainThread(() => {
                    if (m_SelfSeatID == 0 || GetPlayerInfoForSeatID(m_SelfSeatID).Bet > 0)
                    {
                        m_StateManage.m_StateBetting.RealExit();
                        Common.ConfigSortTime = (int)data.GameStateNotify.Countdown / 1000;
                        m_StateManage.ChangeState(STATE.STATE_SORTING);
                    }
                    else
                    {
                        m_GameConsole.ShowWaitingAnime();
                    }
                });
                break;

            case Msg.GameState.ConfirmCombine:
                Loom.QueueOnMainThread(() => {
                    m_StateManage.m_StateSorting.AutoSortConfrm();
                });
                break;

            case Msg.GameState.Show:
                Loom.QueueOnMainThread(() => {
                    m_StateManage.m_StateBetting.RealExit();
                    m_GameConsole.HideWaitAnime();

                    ResultEvent(data.GameStateNotify.Result);
                    m_StateManage.ChangeState(STATE.STATE_SHOWHAND);
                });
                break;

            case Msg.GameState.Result:
                Loom.QueueOnMainThread(() => {
                    //m_StateManage.m_StateSeat.UpdateSeatScore();
                    Common.ConfigFinishTime = (int)data.GameStateNotify.Countdown / 1000;
                    m_StateManage.ChangeState(STATE.STATE_FINISH);
                });
                break;
            }
            break;

        case MessageID.SitDownNotify:
            if (data.SitDownNotify.Type == Msg.SitDownType.Sit)
            {
                Loom.QueueOnMainThread(() => {
                    foreach (PlayerInfo p in Common.CPlayers)
                    {
                        if (p.Uid == data.SitDownNotify.Uid)
                        {
                            p.Score = data.SitDownNotify.Score;
                        }
                    }

                    SetSeatID(data.SitDownNotify.Uid, (int)data.SitDownNotify.SeatId);

                    foreach (PlayerInfo p1 in Common.CPlayers)
                    {
                        Debug.Log(p1.Uid + "===============" + p1.SeatID);
                    }

                    UpdateOrderList();

                    if (m_SelfSeatID == 0 && GetTablePlayersCount() > 1 && Common.CState == Msg.GameState.Ready)
                    {
                        m_Letplay.SetActive(true);
                    }
                });
            }
            break;

        case MessageID.StandUpNotify:
            if (data.StandUpNotify.Reason == StandUpReason.NoActionFor3Hands)
            {
                Loom.QueueOnMainThread(() => {
                    if (m_SelfSeatID == 0)
                    {
                        m_FirstSetBanker = false;
                    }
                    if (data.StandUpNotify.Uid == Common.Uid)
                    {
                        Common.ErrorDialog(PrefabDialog, Canvas.gameObject, Common.ErrorOutdue);
                    }
                });
            }
            else if (data.StandUpNotify.Reason == StandUpReason.CreditPointsOut)
            {
                Loom.QueueOnMainThread(() => {
                    Common.ErrorDialog(PrefabDialog, Canvas.gameObject, Common.ErrorGameCreditMax);
                });
            }

            Loom.QueueOnMainThread(() => {
                m_StateManage.m_StateBetting.UpdateChipsUI(GetSeatIDForPlayerID(data.StandUpNotify.Uid), 0);
                SetSeatID(data.StandUpNotify.Uid, -1);
                UpdateOrderList();
                if (GetTablePlayersCount() <= 1 && Common.CState == Msg.GameState.Ready)
                {
                    m_Letplay.SetActive(false);
                }
            });

            break;

        case MessageID.JoinRoomNotify:
            Loom.QueueOnMainThread(() => {
                PlayerInfo p = new PlayerInfo();
                p.Uid        = data.JoinRoomNotify.Uid;
                p.Name       = data.JoinRoomNotify.Name;
                p.FB_avatar  = data.JoinRoomNotify.Avatar;
                p.SeatID     = -1;
                Common.CPlayers.Add(p);

                foreach (PlayerInfo p1 in Common.CPlayers)
                {
                    Debug.Log(p1.Uid + "===============" + p1.SeatID);
                }
            });
            break;

        case MessageID.KickNotify:
            Loom.QueueOnMainThread(() => {
                if (data.KickNotify.Type == Msg.KickType.StopServer)
                {
                    Common.ErrorDialog(PrefabDialog, Canvas.gameObject, Common.ErrorKickGame, Common.CloseServerDialog);
                }
                else
                {
                    Common.CloseServerDialog(null);
                }
            });
            break;

        case MessageID.NoticesNotify:
            Loom.QueueOnMainThread(() => {
                foreach (Msg.Notice s in data.NoticesNotify.Notices)
                {
                    if (s.Type == Msg.NoticeType.HorseLamp)
                    {
                        NoticeMessage nm = new NoticeMessage();
                        nm.text          = s.Content;
                        nm.times         = 3;
                        Common.GameNotices.Add(nm);
                    }
                    else
                    {
                        Common.ErrorDialog(PrefabDialog, Canvas.gameObject, s.Content);
                    }
                }

                NoticeBar.OnPlay();
            });
            break;

        case MessageID.LeaveRoomNotify:
            Loom.QueueOnMainThread(() => {
                LeaveRoomEvent(data.LeaveRoomNotify.Uid);
                if (GetTablePlayersCount() <= 1 && Common.CState == Msg.GameState.Ready)
                {
                    m_Letplay.SetActive(false);
                }
            });
            break;

        case MessageID.BetNotify:
            Loom.QueueOnMainThread(() => {
                m_StateManage.m_StateBetting.UpdateChipsUI((int)data.BetNotify.SeatId, (int)data.BetNotify.Chips);
            });
            break;
        }
    }
Exemplo n.º 3
0
    public void ResultEvent(RepeatedField <global::Msg.SeatResult> ResultList)
    {
        Common.CSeatResults.Clear();

        for (int i = 0; i < ResultList.Count; i++)
        {
            CSeatResult info = new CSeatResult();
            info.SeatID = (int)ResultList [i].SeatId;

            if ((int)ResultList [i].SeatId != 0)
            {
                info.score = new List <int> (ResultList [i].Scores);
            }

            PlayerInfo p = GetPlayerInfoForSeatID(info.SeatID);
            if (p != null)
            {
                info.Name   = p.Name;
                info.Avatar = p.FB_avatar;
                info.BWin   = p.Score;
            }


            info.autowin = ResultList [i].Autowin;
            info.foul    = ResultList [i].Foul;
            info.Win     = ResultList [i].Win;
            info.Ranks   = ResultList [i].Ranks;

            for (int o = 0; o < ResultList [i].CardGroups.Count; o++)
            {
                Msg.CardGroup cg = ResultList [i].CardGroups[o];
                info.Pres.Add(cg.Cards);
            }
            Common.CSeatResults.Add(info.SeatID, info);

            foreach (PlayerInfo player in Common.CPlayers)
            {
                if (player.Uid == ResultList [i].Uid)
                {
                    player.Score += ResultList [i].Win;
                }
            }
        }


//		uint[] arr = { 1, 2, 3};
//		RepeatedField<uint> arrr = new RepeatedField<uint>{ arr };
//
//		uint[] arr1 = { 4, 5, 6, 7, 8 };
//		RepeatedField<uint> arrr1 = new RepeatedField<uint>{ arr1 };
//
//		uint[] arr2 = { 9, 10, 11, 12, 13 };
//		RepeatedField<uint> arrr2 = new RepeatedField<uint>{ arr2 };
//
//		CSeatResult hinfo = new CSeatResult ();
//		hinfo.Name = "walter";
//		hinfo.Avatar = "";
//		hinfo.Bet = 2000;
//		hinfo.Win = 1200;
//		hinfo.SeatID = 0;
//		hinfo.autowin = true;
//		hinfo.foul = false;
//		hinfo.Pres.Add (arrr);
//		hinfo.Pres.Add (arrr1);
//		hinfo.Pres.Add (arrr2);
//
//		hinfo.score.Add (1);
//		hinfo.score.Add (-1);
//		hinfo.score.Add (-1);
//
//
//		Common.CSeatResults.Add (0, hinfo);
//		Common.CSeatResults.Add (1, hinfo);
//		//SeatResults.Add (2, hinfo);
//		Common.CSeatResults.Add (3, hinfo);
    }