Пример #1
0
        static public void Init(Player player, Seat seat)
        {
            var transform = PoolMan.Spawn("PlayerSelf", seat.transform);

            transform.GetComponent <RectTransform>().anchoredPosition = Vector3.zero;
            transform.GetComponent <PlayerSelf>().init(player, seat);
        }
Пример #2
0
    public void OnGamerData()
    {
        var go = PoolMan.Spawn("PartnerList");

        go.GetComponent <DOPopup>().Show();
        go.GetComponent <PartnerList>().Init(Uid);
    }
Пример #3
0
    public void OnGamerOptionClick()
    {
        var go = PoolMan.Spawn("GamerOption");

        go.GetComponent <DOPopup>().Show();
        go.GetComponent <GamerOption>().Init(enterLimit, seatLimit, talkLimit, uid, true);
    }
Пример #4
0
    public void OnGamerOptionClick()
    {
        var transform = PoolMan.Spawn("GamerOption");

        transform.GetComponent <DOPopup>().Show();
        transform.GetComponent <GamerOption>().Init(enterLimit, seatLimit, talkLimit, Uid);
    }
Пример #5
0
    public void OnClick()
    {
        var transform = PoolMan.Spawn(RoomMessagePrefab);

        transform.GetComponent <DOPopup>().Show();
        transform.GetComponent <RoomMessage>().Init();
    }
Пример #6
0
    public void GamerListPage()
    {
        GetComponent <DOPopup>().Close();
        var go = PoolMan.Spawn("GamerList");

        go.GetComponent <DOPopup>().Show();
    }
Пример #7
0
    public void OwnerPage()
    {
        GetComponent <DOPopup>().Close();
        var go = PoolMan.Spawn("OwnerPanel");

        go.GetComponent <DOPopup>().Show();
        go.GetComponent <OwnerPanel>().Init();
    }
Пример #8
0
        private void setPrChips(int value)
        {
            var chip = PoolMan.Spawn("UpChip");

            chip.SetParent(theSeat.transform, false);
            chip.GetComponent <RectTransform>().localScale = Vector3.one;
            chip.SetAsLastSibling();
            chip.GetComponent <ChipsGo>().Create(theSeat, player);
        }
Пример #9
0
    public static SelfCards Create(GameObject prefab, Player player)
    {
        var transform = PoolMan.Spawn(prefab);
        var sc        = transform.GetComponent <SelfCards>();

        sc.player = player;
        sc.addEvents();
        return(sc);
    }
Пример #10
0
    private void renderCards(List <int> outs)
    {
        foreach (var cardNum in outs)
        {
            var transform = PoolMan.Spawn("InsureCard", CardList);
            transform.SetAsLastSibling();
            var card = transform.GetComponent <CardContainer>().CardInstance;

            card.Show(cardNum);

            var toggle = transform.GetComponent <Toggle>();
            toggle.onValueChanged.RemoveAllListeners();             // 先移除事件

            transform.GetComponent <Toggle>().isOn = true;

            togglesDict.Add(cardNum, toggle);

            if (caller.mustBuy || !caller.isBuyer)
            {
                toggle.interactable = false;
            }
            else
            {
                toggle.interactable = true;
            }

            toggle.onValueChanged.AddListener((isOn) => {
                if (isOn)
                {
                    SelectedOuts.Add(cardNum);
                }
                else
                {
                    SelectedOuts.Remove(cardNum);
                }

                SelectedText.text = SelectedOuts.Count.ToString();

                if (SelectedOuts.Count >= togglesDict.Count)
                {
                    SetCheckAllToggle(true);
                }
                else
                {
                    SetCheckAllToggle(false);
                }

                if (caller.SelectedCount == 0)
                {
                    toggle.isOn = true;
                }

                caller.OnSelectedChange(this);
            });
        }
    }
Пример #11
0
    void onClick()
    {
        if (string.IsNullOrEmpty(Uid))
        {
            return;
        }

        var userPopup = PoolMan.Spawn("User");

        userPopup.GetComponent <UserDetail>().Init(Uid);
    }
Пример #12
0
    private void setupAllinPlayers(List <object> allinPlayers, int maxPercent)
    {
        AllinTitle.text = "落后玩家(" + allinPlayers.Count + ")";

        foreach (var obj in allinPlayers)
        {
            var data      = obj as Dictionary <string, object>;
            var playerMes = PoolMan.Spawn("InsureAllInPlayer", AllinPlayersParent.transform);
            playerMes.GetComponent <AllInPlayer>().Init(data, maxPercent);
        }
    }
Пример #13
0
    public void Back()
    {
        GetComponent <DOPopup>().Close();

        if (fromList)
        {
            var go = PoolMan.Spawn("GamerList");
            go.GetComponent <DOPopup>().Show();
        }
        else
        {
            var userPopup = PoolMan.Spawn("User");
            userPopup.GetComponent <UserDetail>().Init(uid);
        }
    }
Пример #14
0
 private void AskPartnersData()
 {
     HTTP.Get("/check-partner", new Dictionary <string, object>()
     {
         { "a_uid", aimUid[0] },
         { "b_uid", aimUid[1] },
         { "room_id", GameData.Shared.Room.Value },
     }, (data) =>
     {
         var partnerData = PoolMan.Spawn("PartnerData");
         partnerData.GetComponent <DOPopup>().Show();
         var dataDic = Json.Decode(data) as Dictionary <string, object>;
         partnerData.GetComponent <PartnerData>().Init(dataDic);
     });
 }
Пример #15
0
    public void ScorePage()
    {
        Transform target;

        if (GameData.Shared.Type.Value == GameType.MTT)
        {
            target = PoolMan.Spawn(MTTScorePagePrefab);
        }
        else
        {
            target = PoolMan.Spawn(ScorePagePrefab);
        }

        target.GetComponent <DOPopup>().Show();
    }
Пример #16
0
    public void OnSave()
    {
        if (requesting)
        {
            return;
        }

        requesting = true;

        HTTP.Post("/remark", new Dictionary <string, object> {
            { "user_id", Uid },
            { "remark", Input.text }
        }, (_) => {
            requesting = false;
            PoolMan.Spawn("User").GetComponent <UserDetail>().Init(Uid);
        });
    }
Пример #17
0
    public void OnClick()
    {
        var type = GameData.Shared.Type.Value;

        if (type == GameType.SNG)
        {
            var SNGMsgPage = PoolMan.Spawn("SNGMsgPage");
            SNGMsgPage.GetComponent <DOPopup>().Show();
            SNGMsgPage.GetComponent <SNGMsgPage>().Init();
        }
        else if (type == GameType.MTT)
        {
            var MTTMsgPage = PoolMan.Spawn("MTTMsg");
            MTTMsgPage.GetComponent <DOPopup>().Show();
            MTTMsgPage.GetComponent <MTTMsgPage.MTTMsg>().Init();
        }
    }
Пример #18
0
    void Awake()
    {
        RxSubjects.TakeCoin.Subscribe((e) => {
            if (e.Data != null)
            {
                GameData.Shared.Coins = e.Data.Int("coins");
            }

            //根据类别生成不同预制体
            Transform transform;
            if (!GameData.Shared.IsMatch())
            {
                transform = PoolMan.Spawn("Supplement");
            }
            else
            {
                transform = PoolMan.Spawn("JoinMatch");
            }


            transform.GetComponent <DOPopup>().Show(() => {
                var player = GameData.Shared.GetMyPlayer();

                if (player.Index == -1 || player.Bankroll.Value > 0)
                {
                    return;
                }

                Connect.Shared.Emit("unseat");
            });
        }).AddTo(this);

        RxSubjects.Bye.Subscribe((e) => {
            var type = e.Data.Int("type");

            if (type == 2)
            {
                PokerUI.ConflictAlert();
            }
            else if (type == 3)
            {
                PokerUI.DisAlert("您已被房主踢出牌局");
            }
        }).AddTo(this);
    }
Пример #19
0
    public static Transform Spawn()
    {
        if (instance == null)
        {
            var ins = PoolMan.Spawn("OP", G.UICvs.transform);
            instance = ins;
        }
        else
        {
            if (PoolMan.IsSpawned(instance))
            {
                // skip
            }
            else
            {
                PoolMan.Spawn("OP", G.UICvs.transform);
            }
        }

        return(instance);
    }
Пример #20
0
    public void OnRebuyAddon()
    {
        if (!GameData.MatchData.CanBuyLv())
        {
            return;
        }

        var go = PoolMan.Spawn("RebuyOrAddon");

        go.GetComponent <DOPopup>().Show();

        var ins = go.GetComponent <RebuyOrAddon>();

        if (GameData.MatchData.CanRebuyLv())
        {
            ins.Rebuy();
        }
        else
        {
            ins.AddOn();
        }
    }
Пример #21
0
    void Start()
    {
        GameData.Shared.ShowAudit.Subscribe((show) =>
        {
            if (!show)
            {
                if (auditMsg != null)
                {
                    auditMsg.GetComponent <DOPopup>().Close();
                    auditMsg = null;
                }

                return;
            }

            auditMsg = PoolMan.Spawn("AuditMsg").GetComponent <AuditMsg>();
            auditMsg.GetComponent <AuditMsg>().Click = () =>
            {
                Commander.Shared.Audit();
            };

            auditMsg.GetComponent <DOPopup>().Show(modal: false, singleton: false);
        }).AddTo(this);
    }
Пример #22
0
 public void OnClickHoldCardPage()
 {
     PoolMan.Spawn(HoldCardPagePrefab);
 }
Пример #23
0
    private void registerEvents()
    {
        // 只允许初始化一次
        if (isReady)
        {
            return;
        }

        GameData.Shared.LeftTime.Subscribe((value) => {
            if (!GameData.Shared.GameStarted.Value)
            {
                setText(TimeLeftGo, "未开始");
                return;
            }

            setText(TimeLeftGo, _.SecondStr(value));

            if (GameData.Shared.IsMatch())
            {
                return;
            }

            if (value > 5 * 60)
            {
                hasShowEnding = false;
            }
            else
            {
                if (!hasShowEnding)
                {
                    PokerUI.Toast("牌局将在5分钟内结束");
                }

                hasShowEnding = true;
            }
        }).AddTo(this);

        RxSubjects.UnSeat.Subscribe((e) => {
            var uid = e.Data.String("uid");
            if (uid == GameData.Shared.Uid && e.Data.Int("type") == 2)
            {
                PokerUI.Alert("您已连续3次超时,先站起来休息下吧~");
            }
        }).AddTo(this);

        GameData.Shared.Ante.Subscribe((value) => {
            setBBText();
        }).AddTo(this);

        GameData.Shared.Straddle.Subscribe((value) => {
            setBBText();
        }).AddTo(this);

        GameData.Shared.PlayerCount.Where((value) => value > 0).Subscribe((value) => {
            setupSeats(value);
        }).AddTo(this);

        RxSubjects.Connecting.Subscribe((stat) => {
            LoadingModal.transform.SetAsLastSibling();
            LoadingModal.SetActive(stat);
        }).AddTo(this);

        RxSubjects.Seating.Subscribe((action) =>
        {
            foreach (var go in Seats)
            {
                var seat = go.GetComponent <Seat>();
                if (action)
                {
                    seat.Hide();
                }
                else if (!GameData.Shared.Players.ContainsKey(seat.Index))
                {
                    seat.Show();
                }
            }
            ExpressionButton.SetActive(action);
        }).AddTo(this);

        subsPublicCards();
        subsPlayer();
        subsRoomSetting();

        RxSubjects.GameReset.Subscribe((_) => {
            infoGo.SetActive(false);
            PokerUI.DestroyElements();
        }).AddTo(this);

        RxSubjects.Emoticon.Subscribe((e) =>
        {
            if (GameSetting.emoticonClose)
            {
                return;
            }

            int fromSeatIndex = e.Data.Int("seat");
            int toSeatIndex   = e.Data.Int("toseat");
            int pid           = e.Data.Int("pid");
            int[] canTurnEmo  = { 4, 5, 6, 7, 10, 12 };
            bool isToMe       = false;

            var fromSeatPos = new Vector2(0, 1920);
            var toSeat      = Seats[0];

            foreach (var seat in Seats)
            {
                if (seat.GetComponent <Seat>().Index == fromSeatIndex && fromSeatIndex > -1)
                {
                    fromSeatPos = seat.GetComponent <RectTransform>().anchoredPosition;
                }

                if (seat.GetComponent <Seat>().Index == toSeatIndex)
                {
                    toSeat = seat;

                    if (toSeatIndex == GameData.Shared.FindPlayerIndex(GameData.Shared.Uid))
                    {
                        isToMe = true;
                    }
                }
            }
            var em = PoolMan.Spawn("Emoticon/Emo" + pid);
            em.GetComponent <Emoticon>().Init(fromSeatPos, toSeat, isToMe, canTurnEmo.Contains(pid));
        }).AddTo(this);

        var expressions = new Dictionary <string, Transform>();

        RxSubjects.Expression.Subscribe((e) => {
            var expressionName = e.Data.String("expression");
            var uid            = e.Data.String("uid");

            if (expressions.ContainsKey(uid))
            {
                PoolMan.Despawn(expressions[uid]);
                expressions.Remove(uid);
            }

            var expression   = PoolMan.Spawn("Expression");
            expressions[uid] = expression;             // 保存起来

            Transform parent;

            if (uid == GameData.Shared.Uid)
            {
                parent = ExpressionButton.transform;
                //有可能出现点击表情时,玩家已经站起的现象
                if (!parent.gameObject.activeInHierarchy)
                {
                    return;
                }
            }
            else
            {
                var seatIndex = e.Data.Int("seat");
                var aimSeat   = Seats[0];

                foreach (var seat in Seats)
                {
                    if (seat.GetComponent <Seat>().Index == seatIndex)
                    {
                        aimSeat = seat;
                        break;
                    }
                }

                parent = aimSeat.GetComponentInChildren <PlayerOppo>().transform;
            }

            expression.GetComponent <Expression>().SetTrigger(expressionName, parent, () => {
                expressions.Remove(uid);
            });
        }).AddTo(this);

        RxSubjects.MatchLook.Subscribe((e) => {
            if (GameData.Shared.Type.Value != GameType.MTT)
            {
                return;
            }

            var state = e.Data.Int("match_state");

            // 比赛未开始
            if (state < 10)
            {
                return;
            }

            var myself = e.Data.Dict("myself");
            if (myself.Int("rank") >= 0)
            {
                PokerUI.ToastThenExit("您已被淘汰");
            }
        }).AddTo(this);

        RxSubjects.MatchRank.Subscribe((json) => {
            // 输了之后以游客身份旁观
            GameData.Shared.IsMatchState = false;

            var SNGWinner = PoolMan.Spawn("MatchWinner");
            SNGWinner.GetComponent <DOPopup>().ShowModal(new Color(0, 0, 0, 0.6f), closeOnClick: false);
            SNGWinner.GetComponent <MatchWinner>().Init(json.Data);
        }).AddTo(this);

        RxSubjects.ShowAudio.Where(isGuest).Subscribe((json) => {
            var N    = JSON.Parse(json);
            var name = N["name"].Value;
            SpkText.ShowMessage(String.Format("{0}发送了一段语音", name));
        }).AddTo(this);

        RxSubjects.SendChat.Where(isGuest).Subscribe((json) => {
            var N    = JSON.Parse(json);
            var name = N["name"].Value;
            var text = N["text"].Value;

            SpkText.ShowMessage(String.Format("{0}: {1}", name, text));
        }).AddTo(this);

        RxSubjects.Award27.Subscribe((e) => {
            var win27Emo = PoolMan.Spawn("Win27Emo");
            win27Emo.transform.SetParent(G.UICvs.transform, false);
            win27Emo.GetComponent <RectTransform>().anchoredPosition = Vector2.zero;
        }).AddTo(this);

        RxSubjects.GameOver.Subscribe((e) => {
            if (GameData.Shared.IsMatch())
            {
                return;
            }

            var type  = GameData.Shared.Type.Value;
            var count = GameData.Shared.PublicCards.Count;

            if (count < 5 && type != GameType.KingThree)
            {
                SeeLeftCard.SetActive(true);
            }
            else if (count < 3 && type == GameType.KingThree)
            {
                SeeLeftCard.SetActive(true);
            }
        }).AddTo(this);

        RxSubjects.GameStart.Subscribe((e) => {
            gameReload();
            infoGo.SetActive(false);
        }).AddTo(this);

        RxSubjects.Look.Subscribe((e) => {
            gameReload();

            if (GameData.Shared.InGame)
            {
                infoGo.SetActive(false);
            }
        }).AddTo(this);

        RxSubjects.Pass.Subscribe((e) => {
            var type = GameData.Shared.Type.Value;

            if (!GameData.Shared.IsMatch())
            {
                var msg = "记分牌带入成功";

                if (GameData.Shared.InGame)
                {
                    msg += "(下一手生效)";
                }
                PokerUI.Toast(msg);
            }
            else if (type == GameType.SNG)
            {
                PokerUI.Toast("报名成功");
            }
            else if (type == GameType.MTT)
            {
                var inc = e.Data.Int("inc_bankroll");
                PokerUI.Toast(string.Format("成功购买{0}记分牌(下一手生效)", inc));
            }
        }).AddTo(this);

        RxSubjects.SomeOneSeeCard.Subscribe((e) => {
            var name = e.Data.String("name");

            var go   = (GameObject)GameObject.Instantiate(SeeCardTips, G.UICvs.transform);
            var cvg  = go.GetComponent <CanvasGroup>();
            var text = go.transform.Find("Text").GetComponent <Text>();

            text.text = String.Format("<color=#4FC3F7FF>{0}</color>看了剩余公共牌", name);

            go.SetActive(true);
            cvg.alpha = 0;
            go.transform.SetParent(SeeCardTable.transform);

            cvg.DOFade(1, 0.2f).OnComplete(() => {
                Observable.Timer(TimeSpan.FromSeconds(2.5)).Subscribe((tmp) => {
                    cvg.DOFade(0, 0.2f).OnComplete(() => {
                        Destroy(go);
                    });
                }).AddTo(this);
            });
        }).AddTo(this);

        RxSubjects.ToInsurance.Subscribe((e) =>
        {
            GameData.Shared.InsuranceState.Value = true;

            var InsurancePopup = PoolMan.Spawn("Insurance");
            InsurancePopup.GetComponent <Insurance>().Init(e.Data, true);
        }).AddTo(this);

        RxSubjects.ShowInsurance.Subscribe((e) =>
        {
            var InsurancePopup = PoolMan.Spawn("Insurance");
            InsurancePopup.GetComponent <Insurance>().Init(e.Data, false);
        }).AddTo(this);

        RxSubjects.RaiseBlind.Subscribe((e) => {
            var bb = e.Data.Int("big_blind");
            var cd = e.Data.Int("blind_countdown");

            GameData.Shared.BB = bb;
            GameData.Shared.LeftTime.OnNext(cd);
            GameData.Shared.Ante.Value = e.Data.Int("ante");
            setBBText();

            PokerUI.Toast(string.Format("盲注已升至{0}/{1}", bb / 2, bb));

            if (GameData.Shared.Type.Value == GameType.MTT)
            {
                var lv = e.Data.Int("blind_lv");

                // 下一级别无法重购
                if (lv == GameData.MatchData.LimitLv - 2)
                {
                    PokerUI.Toast("本级别过后将无法再重购");
                }
                else if (lv == GameData.MatchData.LimitLv - 1)
                {
                    PokerUI.Toast("本级别过后将无法再增购");
                }
            }
        }).AddTo(this);

        RxSubjects.OffScore.Subscribe((e) => {
            var type = e.Data.Int("type");
            if (type == 0)
            {
                PokerUI.Toast("您已提前下分,将在本局结束后结算");
                return;
            }

            if (type != 1)
            {
                return;
            }

            var name   = e.Data.String("name");
            var avatar = e.Data.String("avatar");

            var dt       = e.Data.Dict("data");
            var takecoin = dt.Int("takecoin");
            var profit   = dt.Int("bankroll") - takecoin;

            PoolMan.Spawn("OffScore").GetComponent <OffScore>().Show(avatar, takecoin, profit);

            // 已下分,bankroll为0
            GameData.Shared.Bankroll.Value = 0;
        }).AddTo(this);

        RxSubjects.ToAddOn.Subscribe((e) => {
            var go = PoolMan.Spawn("RebuyOrAddon");
            go.GetComponent <DOPopup>().Show(closeOnClick: false);
            go.GetComponent <RebuyOrAddon>().AddOn(true);
        }).AddTo(this);

        RxSubjects.ToRebuy.Subscribe((e) =>
        {
            var go = PoolMan.Spawn("RebuyOrAddon");
            go.GetComponent <DOPopup>().Show(closeOnClick: false);
            go.GetComponent <RebuyOrAddon>().Rebuy(true);
        }).AddTo(this);

        RxSubjects.GameEnd.Subscribe((e) => {
            // 关闭连接
            Connect.Shared.CloseImmediate();

            if (MatchWinner.IsSpawned)
            {
                return;
            }

            // 获取roomID,调用ExitCb后无法获取
            var roomID  = GameData.Shared.Room.Value;
            var matchID = GameData.Shared.MatchID;
            var ID      = "";
            var page    = "";
            // 清理
            External.Instance.ExitCb(() => {
                switch (GameData.Shared.Type.Value)
                {
                case GameType.SNG:
                    ID   = roomID;
                    page = "record_sng.html";
                    break;

                case GameType.MTT:
                    ID   = matchID;
                    page = "record_mtt.html";
                    break;

                default:
                    ID   = roomID;
                    page = "record.html";
                    break;
                }

                Commander.Shared.GameEnd(ID, page);
            });
        }).AddTo(this);

        RxSubjects.MTTMatch.Subscribe((e) => {
            if (GameData.Shared.Type.Value != GameType.MTT)
            {
                return;
            }

            var type = e.Data.Int("type");

            if (type == 3)
            {
                var player = GameData.Shared.GetMyPlayer();

                if (player.IsValid())
                {
                    return;
                }

                var roomId = e.Data.String("data");
                Connect.Shared.Enter(roomId, () => {
                    getRoomEnter();
                });
            }
            else if (type == 6)
            {
                PokerUI.Toast("即将进入钱圈");
            }
        }).AddTo(this);
        // Connect.Shared.Enter(GameData.Shared.Room.Value, () => {
        //  getRoomEnter();
        // });
    }
Пример #24
0
    public static ModalHelper Create()
    {
        var transform = PoolMan.Spawn("Modal");

        return(transform.GetComponent <ModalHelper>());
    }
Пример #25
0
    public void OnRemark()
    {
        var transform = PoolMan.Spawn("UserRemark");

        transform.GetComponent <UserRemark>().Show(Uid, remark);
    }
Пример #26
0
    public void ShowMenu()
    {
        var popup = PoolMan.Spawn(MenuPrefab);

        popup.GetComponent <DOPopup>().Show();
    }
Пример #27
0
 public void OnShowRecalls()
 {
     PoolMan.Spawn(RecallPagePrefab);
 }
Пример #28
0
 public void OnReturn()
 {
     PoolMan.Spawn("User").GetComponent <UserDetail>().Init(Uid);
 }
Пример #29
0
    public void OnClickExpressionPage()
    {
        var expressionPage = PoolMan.Spawn("ExpressionPage");

        expressionPage.GetComponent <DOPopup>().Show();
    }
Пример #30
0
 public void SharkEmo2()
 {
     PoolMan.Spawn("Emoticon/Emo15_Shark").SetParent(G.UICvs.transform, false);
 }