/// <summary> /// 显示该房间的玩家在线状态 /// </summary> /// <param name="userid"></param> public void ShowRoomPlayerStatus(int[] userid) { if (roomInfo.cOpenRoomStatus == 3) { return; } InsteadOpenRoomPanelData ioprd = MahjongLobby_AH.GameData.Instance.InsteadOpenRoomPanelData; int num = 0; //保存玩家信息已经开始的信息 for (int i = 0; i < userid.Length; i++) { if (userid[i] != 0) { ReadyStatus[i].gameObject.SetActive(true); num++; } else { ReadyStatus[i].gameObject.SetActive(false); } } //如果状态是未开始游戏,但是已经坐满了四个玩家,则直接删除当前面板,产生新的游戏面板 if (num == 4) { InsteadOpenRoomPanelData.InsteadOpenStatusNotice notice = new InsteadOpenRoomPanelData.InsteadOpenStatusNotice(); notice.byOpenRoomStatus = 3; notice.sTableNum = roomInfo.iTableNum; notice.iaUserId = roomInfo.iuserId; ioprd.ChangePlayerInsteadMessage(notice); } }
/// <summary> /// 处理代开规则面板的关闭按钮 /// </summary> void HandleInsteadRuleCloseBtn() { InsteadOpenRoomPanelData iorpd = GameData.Instance.InsteadOpenRoomPanelData; iorpd.InsteadRulePanelShow = false; UpdateShow(); }
/// <summary> /// 处理代开记录按钮 /// </summary> void HandleInsteadOpenRecordBtn() { Debug.LogError("===================================1"); InsteadOpenRoomPanelData iorpd = GameData.Instance.InsteadOpenRoomPanelData; //获取代理的历史开房记录 string str = LobbyContants.MAJONG_PORT_URL + iorpd.url_suffix; if (SDKManager.Instance.IOSCheckStaus == 1) { str = LobbyContants.MAJONG_PORT_URL_T + iorpd.url_suffix; } Dictionary <string, string> value = new Dictionary <string, string>(); value.Add("uid", GameData.Instance.PlayerNodeDef.iUserId.ToString()); value.Add("mode", "2"); anhui.MahjongCommonMethod.Instance.GetPlayerMessageData_IE(str, value, iorpd.GetMessageData, iorpd.json_title, 0); //根据代开记录,显示玩家的信息 UIMainView.Instance.InsteadOpenRoomPanel.InsteadOpenRecord.SetActive(true); UIMainView.Instance.InsteadOpenRoomPanel.InstaedOPenRoomStatus.SetActive(false); iorpd.iBtnStatus = 2; SystemMgr.Instance.InsteadOpenRoomSystem.UpdateShow(); UIMainView.Instance.InsteadOpenRoomPanel.Delay(); }
/// <summary> /// 处理代开房间按钮 /// </summary> void HandleInsteadOpenBtn() { //删除之前的代开房间信息 UIMainView.Instance.InsteadOpenRoomPanel.Deleteprefab(); UIMainView.Instance.InsteadOpenRoomPanel.InsteadOpenRecord.SetActive(false); UIMainView.Instance.InsteadOpenRoomPanel.InstaedOPenRoomStatus.SetActive(true); InsteadOpenRoomPanelData iorpd = GameData.Instance.InsteadOpenRoomPanelData; float height = UIMainView.Instance.InsteadOpenRoomPanel.ContentSize + (iorpd.OpenRoomInfo_Started.Count % 5) * 225f; UIMainView.Instance.InsteadOpenRoomPanel.Content.GetComponent <RectTransform>().SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, height); if (iorpd.iSpwanPrefabNum == 0) { Debug.LogError("count:" + iorpd.OpenRoomInfo_Started.Count); iorpd.iSpwanPrefabNum = 1; } //处理已经开启的房间,但是没有进入游戏 for (int i = 0; i < iorpd.OpenRoomInfo_UnStart.Count; i++) { UIMainView.Instance.InsteadOpenRoomPanel.SpwanAllRoomStatus(iorpd.OpenRoomInfo_UnStart[i]); } //处理没有开启的房间 for (int i = 0; i < 5 - iorpd.OpenRoomInfo_UnStart.Count; i++) { UIMainView.Instance.InsteadOpenRoomPanel.SpwanAllRoomStatus(null); } iorpd.iBtnStatus = 1; SystemMgr.Instance.InsteadOpenRoomSystem.UpdateShow(); }
void UpdateChildrenCallback(int index, Transform trans) { InsteadOpenRoomPanelData iorpd = GameData.Instance.InsteadOpenRoomPanelData; InsteadOpenRecordMessage room = trans.GetComponent <InsteadOpenRecordMessage>(); room.RoomMessage = iorpd.RoomMessage[index]; room.index = index; room.ShowInsteadRecord(); }
/// <summary> /// 处理代开面板的关闭按钮 /// </summary> void HandleCloseBtn() { InsteadOpenRoomPanelData iorpd = GameData.Instance.InsteadOpenRoomPanelData; iorpd.PanelShow = false; iorpd.isClickInsteadOpenRoom = false; iorpd.isFirstSpwanInsteadRecord = true; UpdateShow(); iorpd.iSpwanPrefabNum = 0; }
/// <summary> /// 初始化代开房间的预置体 /// </summary> public void Deleteprefab() { InsteadOpenRoomPanelData iorpd = GameData.Instance.InsteadOpenRoomPanelData; //删除上面的五个预置体 InsteadOpenMessage[] message_0 = CurrentRoomStatus.GetComponentsInChildren <InsteadOpenMessage>(); for (int i = 0; i < message_0.Length; i++) { Destroy(message_0[i].gameObject); } //更新玩家已经开始游戏的预置体 InsteadOpenMessage[] message_1 = RacingRoomStatus.GetComponentsInChildren <InsteadOpenMessage>(); //先检测玩家的预置体和数据的数量 if (message_1.Length != iorpd.OpenRoomInfo_Started.Count) { //如果数量大于之前的,添加 if (message_1.Length < iorpd.OpenRoomInfo_Started.Count) { //更新已有的界面 for (int i = 0; i < message_1.Length; i++) { message_1[i].roomInfo = iorpd.OpenRoomInfo_Started[i]; } //添加新的界面 for (int i = message_1.Length; i < iorpd.OpenRoomInfo_Started.Count; i++) { SpwanAllRoomStatus(iorpd.OpenRoomInfo_Started[i]); } } else { for (int i = 0; i < iorpd.OpenRoomInfo_Started.Count; i++) { message_1[i].roomInfo = iorpd.OpenRoomInfo_Started[i]; } for (int i = iorpd.OpenRoomInfo_Started.Count; i < message_1.Length; i++) { Destroy(message_1[i].gameObject); } } } }
/// <summary> /// 点击确定按钮 /// </summary> public void HandleOkBtn(int roomId) { GameData gd = GameData.Instance; JoinRoomShowPanelData jrpd = GameData.Instance.JoinRoomShowPanelData; InsteadOpenRoomPanelData iorpd = GameData.Instance.InsteadOpenRoomPanelData; anhui.MahjongCommonMethod.Instance.iParlorId = 0; ////如果玩家是代理,会检测是不是进入的是代开的房间,如果是直接返回 //if (gd.PlayerNodeDef.iIsProxy == 1) //{ // for(int i=0;i<iorpd.OpenRoomInfo_Started.Count;i++) // { // if(iorpd.OpenRoomInfo_Started[i].roomNum==roomId) // { // UIMgr.GetInstance().GetUIMessageView().Show("您无法进入自己的代开房间!"); // HandleClearNumBtn(); // return; // } // } // for (int i = 0; i < iorpd.OpenRoomInfo_UnStart.Count; i++) // { // if (iorpd.OpenRoomInfo_UnStart[i].roomNum == roomId) // { // UIMgr.GetInstance().GetUIMessageView().Show("您无法进入自己的代开房间!"); // HandleClearNumBtn(); // return; // } // } //} //保存进入的房间id anhui.MahjongCommonMethod.Instance.RoomId = string.Format(roomId.ToString(), 6d); //获取服务器编号 Network.Message.NetMsg.ClientRoomNumServerTableReq msg = new Network.Message.NetMsg.ClientRoomNumServerTableReq(); msg.iUserId = GameData.Instance.PlayerNodeDef.iUserId; msg.iRoomNum = roomId; msg.iParlorId = 0; Network.NetworkMgr.Instance.LobbyServer.SendRoomNumSeverTableReq(msg); }
/// <summary> /// 面板更新 /// </summary> public void UpdateShow() { InsteadOpenRoomPanelData iorpd = GameData.Instance.InsteadOpenRoomPanelData; if (iorpd.PanelShow) { gameObject.SetActive(true); GameData.Instance.isShowQuitPanel = false; if (iorpd.iBtnStatus == 1) { OpenRoomStatuBtn[0].SetActive(true); OpenRoomStatuBtn[1].SetActive(true); InsteadRecordBtn[0].SetActive(false); InsteadRecordBtn[1].SetActive(false); } else { OpenRoomStatuBtn[0].SetActive(false); OpenRoomStatuBtn[1].SetActive(false); InsteadRecordBtn[0].SetActive(true); InsteadRecordBtn[1].SetActive(true); } if (iorpd.InsteadRulePanelShow) { InsteadRulePanel.SetActive(true); } else { InsteadRulePanel.SetActive(false); } } else { GameData.Instance.isShowQuitPanel = true; gameObject.SetActive(false); } }
/// <summary> /// 点击代开房间按钮 /// </summary> void HandleInsteadCreatRoom() { GameData gd = GameData.Instance; CreatRoomMessagePanelData crmpd = gd.CreatRoomMessagePanelData; PlayerNodeDef pnd = gd.PlayerNodeDef; InsteadOpenRoomPanelData iorpd = gd.InsteadOpenRoomPanelData; iorpd.OpenRoomInfo_UnStart.Clear(); PlayerPrefs.SetFloat(GameData.RedPoint.FirstOpenInsteadPanel.ToString() + GameData.Instance.PlayerNodeDef.iUserId, 2); ////如果不是代理,让玩家查看代理规则 //if(pnd.iIsProxy != 1) //{ // UIMgr.GetInstance().GetUIMessageView().Show("温馨提示", TextConstant.LOOKDAILI, DailiRule,null,0,false,-1,2,0); // return; //} ////判断代理如果房卡数量小于0个,不让开房 //if ((pnd.iRoomCard + pnd.iFreeCard) < 0) //{ // UIMgr.GetInstance().GetUIMessageView().Show("您的金币数量不足,暂时不能使用代开房间功能哦!", ok); // return; //} ////判断玩家是否是代理 //if (pnd.iIsProxy == 1) //{ // //发送玩家的开房信息请求 // NetMsg.ClientOpenRoomInfoReq msg = new NetMsg.ClientOpenRoomInfoReq(); // msg.iUserId = pnd.iUserId; // Network.NetworkMgr.Instance.LobbyServer.SendOpenRoomInfoReq(msg); // iorpd.isClickInsteadOpenRoom = true; //} }
/// <summary> /// 处理点击确定按钮 /// </summary> void HandleBtnOk() { GameData gd = GameData.Instance; CreatRoomMessagePanelData crmpd = gd.CreatRoomMessagePanelData; InsteadOpenRoomPanelData iorpd = gd.InsteadOpenRoomPanelData; SelectAreaPanelData sapd = GameData.Instance.SelectAreaPanelData; crmpd.PanelShow = false; NetMsg.ClientOpenRoomReq msg = new NetMsg.ClientOpenRoomReq(); msg.iUserId = GameData.Instance.PlayerNodeDef.iUserId; msg.cGameId = (byte)anhui.MahjongCommonMethod.Instance._dicMethodConfig[crmpd.MethodId].gameid; msg.iPlayingMethod = crmpd.MethodId; msg.iCompliment = crmpd.iCompliment; msg.iDisconnectRate = crmpd.iDisconnectRate; msg.iDiscardTime = crmpd.iDiscardTime; msg.iRoomCard = crmpd.iRoomCard; // Debug.LogError("房卡;"+crmpd.iRoomCard); msg.cOpenRoomMode = (byte)crmpd.CreatRoomType; msg.byColorFlag = (byte)crmpd.iColorFlag; msg.caParam = crmpd.roomMessage_; msg.iCountyId = sapd.iCountyId; if (msg.cOpenRoomMode > 1) { msg.iParlorId = GameData.Instance.ParlorShowPanelData.iParlorId; } else { anhui.MahjongCommonMethod.Instance.iParlorId = 0; } // Debug.Log("出牌参数0:" + msg.caParam[0].ToString("X8") + "_" + msg.caParam[2].ToString("X8") + "/n" + "出牌参数1:" + msg.caParam[1].ToString("X8") + "_" + msg.caParam[3].ToString("X8")); // Debug.Log("玩法id:" + msg.iPlayingMethod + ",游戏编号:" + msg.cGameId // + ",开放模式:" + msg.cOpenRoomMode + ",馆主id:" + msg.iParlorId + "县ID:" + msg.iCountyId); //保存玩家的本次创建房间的详细信息 // string willSaveRoomRule = ""; // for (int i = 0; i < msg.caParam.Length; i++) // { // if (i == 0) // { // willSaveRoomRule += msg.caParam[i]; // } // else // { // willSaveRoomRule += ("," + msg.caParam[i]); // } // } // PlayerPrefs.DeleteKey("OpenRoomMsgg"); PlayerPrefs.SetInt("iPlayingMethod", msg.iPlayingMethod); // PlayerPrefs.SetInt("iCountyId", msg.iCountyId); // 开房所属县id // PlayerPrefs.SetString("OpenRoomMsgg", willSaveRoomRule); //如果玩家赞的数量或者断线率或者出牌速度小于房间设置,不让创建房间 if (gd.PlayerNodeDef.iPlayCardAcc > 0 && (gd.PlayerNodeDef.iPlayCardTimeAcc / gd.PlayerNodeDef.iPlayCardAcc) > msg.iDiscardTime && msg.iDiscardTime > 0) { UIMgr.GetInstance().GetUIMessageView().Show("您的出牌速度不满足,自己设置的开房条件"); return; } if (gd.PlayerNodeDef.iGameNumAcc > 0 && ((gd.PlayerNodeDef.iDisconnectAcc / (float)gd.PlayerNodeDef.iGameNumAcc) * 100f) > msg.iDisconnectRate && msg.iDisconnectRate > 0) { UIMgr.GetInstance().GetUIMessageView().Show("您的断线率不满足,自己设置的开房条件"); return; } if (gd.PlayerNodeDef.iCompliment < msg.iCompliment && msg.iCompliment > 0) { UIMgr.GetInstance().GetUIMessageView().Show("您的赞的数量不满足,自己设置的开房条件"); return; } //处理玩家选择的房间信息是否符合要求 NetworkMgr.Instance.LobbyServer.SendOpenRoomReq(msg); //iorpd.PanelShow = false; iorpd.isClickInsteadOpenRoom = false; iorpd.isFirstSpwanInsteadRecord = true; SystemMgr.Instance.InsteadOpenRoomSystem.UpdateShow(); UpdateShow(); }
/// <summary> /// 产生代开房间的预置体,如果玩家关闭之后 /// </summary> void SpwanInsteadOpenRecord() { InsteadOpenRoomPanelData iorpd = GameData.Instance.InsteadOpenRoomPanelData; if (iorpd.isNoRecord) { NoRecord.gameObject.SetActive(true); } else { NoRecord.gameObject.SetActive(false); } if (!iorpd.isFirstSpwanInsteadRecord) { return; } iorpd.isFirstSpwanInsteadRecord = false; //删除玩家的之前的面板 InsteadOpenRecordMessage[] rooms = InsteadOpenRecord.transform.Find("Content").GetComponentsInChildren <InsteadOpenRecordMessage>(); if (rooms.Length > 0) { for (int i = 0; i < rooms.Length; i++) { Destroy(rooms[i].gameObject); } } InsteadOpenRecord.transform.Find("Content").GetComponent <GridLayoutGroup>().enabled = true; InsteadOpenRecord.transform.Find("Content").GetComponent <ContentSizeFitter>().enabled = true; int count = iorpd.RoomMessage.Count; Debug.LogError("count:" + count); if (count <= 0) { return; } if (count > 5) { for (int i = 0; i < 5; i++) { GameObject go = Instantiate(Resources.Load <GameObject>("Lobby/InsteadCreatRoomPanel/InsteadOpenRecord")); go.transform.SetParent(InsteadOpenRecord.transform.Find("Content")); go.transform.localEulerAngles = Vector3.zero; go.transform.localPosition = new Vector3(go.transform.localPosition.x, go.transform.localPosition.y, 0); go.transform.localScale = Vector3.one; go.name = "InsteadOpenRecord" + i; } //初始化数据列表; infinityGridLayoutGroup = InsteadOpenRecord.transform.Find("Content").GetComponent <InfinityGridLayoutGroup>(); infinityGridLayoutGroup.Init(); //Invoke("SetAmount", 0.1f); infinityGridLayoutGroup.SetAmount(iorpd.RoomMessage.Count); infinityGridLayoutGroup.updateChildrenCallback = UpdateChildrenCallback; } else { for (int i = 0; i < count; i++) { GameObject go = Instantiate(Resources.Load <GameObject>("Lobby/InsteadCreatRoomPanel/InsteadOpenRecord")); go.transform.SetParent(InsteadOpenRecord.transform.Find("Content")); go.transform.localEulerAngles = Vector3.zero; go.transform.localPosition = new Vector3(go.transform.localPosition.x, go.transform.localPosition.y, 0); go.transform.localScale = Vector3.one; go.name = "InsteadOpenRecord" + i; InsteadOpenRecordMessage room = go.GetComponent <InsteadOpenRecordMessage>(); room.RoomMessage = iorpd.RoomMessage[i]; room.index = i; room.ShowInsteadRecord(); } } }