Esempio n. 1
0
        /// <summary>
        /// 投票解散房间
        /// </summary>
        private void DismissRoom()
        {
            //用于测试
            //YxDebug.Log(" ============= DismissRoom ========== ");
            //App.GetRServer<DuifenGameServer>().DismissRoom(2);
            //return;
            //

            DismissRoomMgr dismissRoomMgr = App.GetGameManager <PaiJiuGameManager>().DismissRoomMgr;

            //游戏开始了就需要发起投票,否则玩家可以自主决定
            if (App.GetGameData <PaiJiuGameData>().IsPlayed)
            {
                YxMessageBox.Show(new YxMessageBoxData()
                {
                    Msg       = "确定要发起投票,解散房间么?",
                    BtnStyle  = YxMessageBox.LeftBtnStyle | YxMessageBox.RightBtnStyle,
                    IsTopShow = true,
                    Listener  = (box, btnName) =>
                    {
                        if (btnName == YxMessageBox.BtnLeft)
                        {
                            if (!dismissRoomMgr.Container.activeSelf)
                            {
                                App.GetRServer <PaiJiuGameServer>().DismissRoom(2);
                                App.GetRServer <PaiJiuGameServer>().DismissRoom(3);
                            }
                            else
                            {
                                Debug.Log("投票已发起!");
                                YxMessageBox.Show(new YxMessageBoxData
                                {
                                    Msg     = "投票已发起!",
                                    Delayed = 5,
                                });
                                dismissRoomMgr.Container.transform.GetChild(0).gameObject.SetActive(true);
                            }
                        }
                    },
                });
            }
            else
            {
                //房主可以解散房间,玩家则是自己退出房间
                if (App.GameData.SelfSeat == 0)
                {
                    YxMessageBox.Show(new YxMessageBoxData()
                    {
                        Msg       = "确定要解散房间吗?",
                        BtnStyle  = YxMessageBox.LeftBtnStyle | YxMessageBox.RightBtnStyle,
                        IsTopShow = true,
                        Listener  = (box, btnName) =>
                        {
                            if (btnName == YxMessageBox.BtnLeft)
                            {
                                IRequest req = new ExtensionRequest("dissolve", new SFSObject());
                                App.GetRServer <PaiJiuGameServer>().SendRequest(req);
                            }
                        },
                    });
                }
                else
                {
                    YxMessageBox.Show(new YxMessageBoxData()
                    {
                        Msg       = "确定要退出房间么?",
                        BtnStyle  = YxMessageBox.LeftBtnStyle | YxMessageBox.RightBtnStyle,
                        IsTopShow = true,
                        Listener  = (box, btnName) =>
                        {
                            if (btnName == YxMessageBox.BtnLeft)
                            {
                                App.QuitGame();
                            }
                        },
                    });
                }
            }
        }