Example #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);
        }
    }
Example #2
0
    public void ShowPokerFace(int SeatID)
    {
        if (Common.CSeatResults.ContainsKey(SeatID))
        {
            CSeatResult pinfo   = Common.CSeatResults [SeatID];
            Transform   HandObj = Layer.Find("SeatCom/Seat" + SeatID);

            for (int i = 0; i < 3; i++)
            {
                Transform Par = HandObj.Find("Par" + i);

                for (int o = 0; o < Par.childCount; o++)
                {
                    GameObject Poker = Par.GetChild(o).gameObject;
                    Image      image = Poker.GetComponent <Image>();
                    image.sprite = Resources.Load("Image/Poker/" + pinfo.Pres[i][o], typeof(Sprite)) as Sprite;
                }

                if (SeatID == 0)
                {
                    continue;
                }

                Transform ParResult = HandObj.Find("ParResult" + i);
                Image     typeI     = ParResult.Find("Type").GetComponent <Image> ();
                Image     ResI      = ParResult.Find("Res").GetComponent <Image> ();

                if (!pinfo.foul)
                {
                    if (pinfo.score.Count > 0)
                    {
                        if (pinfo.score[i] > 0)
                        {
                            typeI.sprite = Resources.Load("Image/Game/winicon", typeof(Sprite)) as Sprite;
                            ResI.sprite  = Resources.Load("Image/Game/win1", typeof(Sprite)) as Sprite;
                        }
                        else
                        {
                            typeI.sprite = Resources.Load("Image/Game/losticon", typeof(Sprite)) as Sprite;
                            ResI.sprite  = Resources.Load("Image/Game/lost1", typeof(Sprite)) as Sprite;
                        }

                        ParResult.gameObject.SetActive(true);
                    }
                }
            }


            m_StateManage.m_StateSeat.UpdateSeatScore(SeatID, pinfo.BWin, pinfo.BWin + pinfo.Win);
            if (SeatID == 0)
            {
                return;
            }

            string typestr = "";

            if (pinfo.autowin)
            {
                HandObj.Find("Getlucky").gameObject.SetActive(true);
            }
            else
            {
                HandObj.Find("Getlucky").gameObject.SetActive(false);
            }

            if (pinfo.Win < 0)
            {
                typestr = "lost";
                HandObj.Find("Lost").gameObject.SetActive(true);
            }
            else
            {
                typestr = "win";
                HandObj.Find("Win").gameObject.SetActive(true);
            }

            string amount = Mathf.Abs(pinfo.Win).ToString();
            float  left   = 0;
            for (int c = 0; c < amount.Length; c++)
            {
                GameObject t = new GameObject();
                t.AddComponent <Image> ();
                t.GetComponent <Image>().sprite = Resources.Load("Image/Game/" + typestr + amount[c], typeof(Sprite)) as Sprite;
                t.transform.SetParent(HandObj.Find("Number"));
                t.transform.GetComponent <RectTransform> ().sizeDelta = new Vector2(20, 24);
                t.transform.localPosition = new Vector3(left, 0, 0);
                left = left + 18;
            }
        }
    }
Example #3
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;
        }
    }
Example #4
0
    public void ShowResultInfo(bool hasAni = false)
    {
        List <Vector3> poslist = new List <Vector3> ();

        poslist.Add(new Vector3(0, 286, 0));
        poslist.Add(new Vector3(0, 54, 0));
        poslist.Add(new Vector3(0, -165, 0));
        poslist.Add(new Vector3(0, -386, 0));

        List <int> Seats = new List <int> ();

        foreach (KeyValuePair <int, CSeatResult> pair in Common.CSeatResults)
        {
            Seats.Add(pair.Key);
        }
        Seats.Sort();

        int index = 0;

        foreach (int seatid in Seats)
        {
            CSeatResult hInfo = Common.CSeatResults[seatid];

            GameObject PreInfoObj = (GameObject)Instantiate(m_GameController.m_PrefabPreInfo);
            PreInfoObj.transform.SetParent(Layer.Find("PreInfoCom"));

            if (hasAni)
            {
                PreInfoObj.transform.localPosition = new Vector3(0, -720, 0);
            }

            UICircle avatar = (UICircle)Instantiate(m_GameController.m_PrefabAvatar);
            avatar.transform.SetParent(PreInfoObj.transform.Find("Avatar"));
            avatar.GetComponent <RectTransform> ().sizeDelta = new Vector2();
            avatar.transform.localPosition = new Vector3();
            avatar.GetComponent <RectTransform> ().sizeDelta = new Vector2(60, 60);

            if (string.IsNullOrEmpty(hInfo.Avatar))
            {
                avatar.UseDefAvatar();
            }
            else
            {
                StartCoroutine(Common.Load(avatar, hInfo.Avatar));
            }

            if (seatid == 0)
            {
                PreInfoObj.transform.Find("BBorder").gameObject.SetActive(true);
                PreInfoObj.transform.Find("BName").GetComponent <Text> ().text = hInfo.Name;
            }
            else
            {
                PreInfoObj.transform.Find("PBorder").gameObject.SetActive(true);
                PreInfoObj.transform.Find("PName").GetComponent <Text> ().text = hInfo.Name;
            }


            for (int i = 0; i < hInfo.Pres.Count; i++)
            {
                RepeatedField <uint> pInfo = hInfo.Pres [i];

                for (int o = 0; o < pInfo.Count; o++)
                {
                    Transform Poker = PreInfoObj.transform.Find("Hand" + i + "/Poker" + o);
                    Image     image = Poker.GetComponent <Image>();
                    image.sprite = Resources.Load("Image/Poker/" + pInfo[o], typeof(Sprite)) as Sprite;
                }
            }

            Transform number  = PreInfoObj.transform.Find("Amount");
            string    typestr = "";

            if (hInfo.Win < 0)
            {
                typestr = "lost";
            }
            else
            {
                typestr = "win";
            }

            string amount = Mathf.Abs(hInfo.Win).ToString();
            float  left   = 0;
            for (int c = amount.Length - 1; c >= 0; c--)
            {
                GameObject t = new GameObject();
                t.AddComponent <Image> ();
                t.GetComponent <Image>().sprite = Resources.Load("Image/Game/" + typestr + amount[c], typeof(Sprite)) as Sprite;
                t.transform.SetParent(number);
                t.transform.GetComponent <RectTransform> ().sizeDelta = new Vector2(20, 24);
                t.transform.localPosition = new Vector3(left, 0, 0);
                left = left - 18;

                if (c == 0)
                {
                    GameObject icon = new GameObject();
                    icon.AddComponent <Image> ();
                    icon.GetComponent <Image>().sprite = Resources.Load("Image/Game/" + typestr + "icon", typeof(Sprite)) as Sprite;
                    icon.transform.SetParent(number);
                    icon.transform.GetComponent <RectTransform> ().sizeDelta = new Vector2(20, 24);
                    icon.transform.localPosition = new Vector3(left, 0, 0);
                }
            }

            float right = number.localPosition.x - 18 * amount.Length;
            if (hInfo.autowin)
            {
                PreInfoObj.transform.Find("GetLucky").gameObject.SetActive(true);
                PreInfoObj.transform.Find("GetLucky").localPosition = new Vector3(right, PreInfoObj.transform.Find("GetLucky").localPosition.y, 0);
            }

            if (hInfo.foul)
            {
                PreInfoObj.transform.Find("Foul").gameObject.SetActive(true);
                PreInfoObj.transform.Find("Foul").localPosition = new Vector3(right, PreInfoObj.transform.Find("GetLucky").localPosition.y, 0);
            }

            if (hasAni)
            {
                PreInfoObj.transform.DOLocalMoveY(poslist [index].y, 0.25f).SetDelay((index + 1) * 0.17f);
            }
            else
            {
                PreInfoObj.transform.localPosition = poslist [index];
            }

            PreInfoObj.transform.localScale = new Vector3(1, 1, 1);

            index++;
        }
    }
Example #5
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);
    }