示例#1
0
文件: RoomMessage.cs 项目: rfHu/poker
    public void Pause()
    {
        string f;
        int    paused;

        if (GameData.Shared.Paused.Value > 0 && GameData.Shared.GameStarted.Value)
        {
            f      = "start";
            paused = 1;
        }
        else
        {
            f      = "pause";
            paused = 0;
        }

        GameData.Shared.Paused.OnNext(paused);

        Connect.Shared.Emit(new Dictionary <string, object>()
        {
            { "f", f },
            { "args", "0" }
        }, (data, err) =>
        {
            if (err == 1301)
            {
                PokerUI.Alert("游戏还未开始");
            }

            GetComponent <DOPopup>().Close();
        });
    }
示例#2
0
 public static void PayFor(Action cb)
 {
     PokerUI.Alert("金币不足,请购买", () => {
         Commander.Shared.PayFor();
         PokerUI.RemoveDialog();
         cb();
     }, null);
 }
示例#3
0
文件: MenuPopup.cs 项目: rfHu/poker
    public void ExchangeMoney()
    {
        var text = "将提前为您结算牌局,是否继续?";

        PokerUI.Alert(text, () =>
        {
            Connect.Shared.Emit("offscore");
        }, null);

        GetComponent <DOPopup>().Close();
    }
示例#4
0
    static public DialogAlert DisAlert(string msg)
    {
        if (Connect.Shared == null)
        {
            return(null);
        }

        var alert = PokerUI.Alert(msg, External.Instance.ExitCb);

        Connect.Shared.CloseImmediate();

        return(alert);
    }
示例#5
0
 public void OnFoldClick()
 {
     if (canCheck)
     {
         PokerUI.Alert("当前可以看牌,您确定要弃牌?", () => {
             OPS.Fold();
         }, null);
     }
     else
     {
         OPS.Fold();
     }
 }
示例#6
0
文件: Seat.cs 项目: rfHu/poker
    public void OnClick()
    {
        if (GameData.MyCmd.Unseat)
        {
            return;
        }

        if (GameData.Shared.Players.ContainsKey(Index))
        {
            return;
        }

        if (GameData.Shared.MySeat >= 0)
        {
            return;
        }

        if (GameData.Shared.GPSLimit.Value)
        {
            var text = "为保证公平竞技,请在设置—隐私—定位服务中开启位置权限";

                        #if UNITY_ANDROID
            var cmd = new AndroidCommander();
            var loc = cmd.GetLocation();

            if (loc == "0")
            {
                PokerUI.Alert(text);
            }
            else
            {
                var locArray = loc.Split("&".ToCharArray());

                takeSeat(new float[] {
                    float.Parse(locArray[0]),
                    float.Parse(locArray[1])
                });
            }
                        #else
            StartCoroutine(Commander.Shared.Location(takeSeat, () => {
                PokerUI.Alert(text);
            }));
                        #endif
        }
        else
        {
            takeSeat(new float[] { 0, 0 });
        }

        RxSubjects.ChangeVectorsByIndexAnimate.OnNext(Index);
    }
示例#7
0
文件: RoomMessage.cs 项目: rfHu/poker
    public void Stop()
    {
        GetComponent <DOPopup>().Close();

        // 二次确定
        PokerUI.Alert("确定提前结束牌局", () =>
        {
            Connect.Shared.Emit(new Dictionary <string, object>()
            {
                { "f", "pause" },
                { "args", "3" }
            });
        }, null);
    }
示例#8
0
文件: MenuPopup.cs 项目: rfHu/poker
    public void Exit()
    {
        GetComponent <DOPopup>().Close();

        var player = GameData.Shared.GetMyPlayer();

        if (player.IsValid() && player.InGame && player.Chips > 0)
        {
            PokerUI.Alert("现在退出将直接弃牌,是否强行退出?", exit, null);
        }
        else
        {
            exit();
        }
    }
示例#9
0
文件: Seat.cs 项目: rfHu/poker
    private void takeSeat(float[] pos)
    {
        // 坐下
        Connect.Shared.Emit(
            new Dictionary <string, object>()
        {
            { "f", "takeseat" },
            { "args", new Dictionary <string, object> {
                  { "seat", Index },
                  { "position_x", pos[0] },
                  { "position_y", pos[1] }
              } }
        }, (data, e) => {
            if (e != 0)
            {
                PokerUI.Alert("无法入座");
                return;
            }

            var err = data.Int("err");
            if (err == 0)
            {
                return;
            }

            string text = "";

            if (err == 1103)
            {
                text = "您与某玩家IP地址相同,不能参与本牌局";
            }
            else if (err == 1104)
            {
                text = "您与某玩家距离过近,不能参与本牌局";
            }
            else if (err == 1106)
            {
                text = "您已提前下分,请参与其他牌局";
            }
            else
            {
                return;
            }

            PokerUI.Alert(text);
        }
            );
    }
示例#10
0
文件: MenuPopup.cs 项目: rfHu/poker
    public void Standup()
    {
        if (!GameData.MyCmd.Unseat)
        {
            return;
        }

        var player = GameData.Shared.GetMyPlayer();

        if (player.IsValid() && player.Chips > 0 && player.InGame)
        {
            PokerUI.Alert("站起将直接弃牌,是否继续?", standup, null);
        }
        else
        {
            standup();
        }

        gameObject.GetComponent <DOPopup>().Close();
    }
示例#11
0
 public void OnClickEnter()
 {
     if (hasChacked)
     {
         AskPartnersData();
     }
     else
     {
         PokerUI.Alert("请确认是否支付 <color=#ffca28>" + checkFee + "金币</color>", (() =>
         {
             if (GameData.Shared.Coins < 100)
             {
                 _.PayFor(() =>
                 {
                     RxSubjects.TakeCoin.OnNext(new RxData());
                 });
             }
             else
             {
                 AskPartnersData();
             }
         }), null);
     }
 }
示例#12
0
文件: Controller.cs 项目: rfHu/poker
    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();
        // });
    }