/// <summary> /// 产生规则的信息 /// </summary> /// <param name="index"></param> void SpwanMethod(int index) { int num_MultiChoiceBtn = 0; //表示隐藏多选按钮数量 //int num_OnlyOneChoice = 0; //表示隐藏多选按钮数量 MahjongCommonMethod mcm = MahjongCommonMethod.Instance; MahjongLobby_AH.Data.CreatRoomMessagePanelData cd = MahjongLobby_AH.GameData.Instance.CreatRoomMessagePanelData; //删除规则 for (int i = 0; i < RuleParent.Length - 1; i++) { Toggle[] tog = new Toggle[RuleParent[i].GetComponentsInChildren <Toggle>().Length]; tog = RuleParent[i].GetComponentsInChildren <Toggle>(); if (tog.Length > 0) { for (int k = 0; k < tog.Length; k++) { Destroy(tog[k].gameObject); } } } #region 托管条显示不显示 /////////////////////////////////////////////////////////// if (cd.roomMessage_[5] > 0) { TuoGuan.SetActive(true); GameObject gotuoguan = null; m_GameRule.enabled = true; m_GameRule.transform.GetChild(0).GetChild(0).transform.SetParent(m_GameRule.transform.GetChild(0)); m_GameRule.transform.GetChild(0).GetChild(0).transform.localPosition = new Vector3(0, 0, 0); for (int i = 0; i < 4; i++) { gotuoguan = Instantiate(Resources.Load <GameObject>("Lobby/PlayerMethodPanel/OnlyOneChoice")); gotuoguan.GetComponent <Toggle>().group = RuleParent[3].GetComponent <ToggleGroup>(); gotuoguan.name = "OnlyOneChoice"; gotuoguan.transform.SetParent(RuleParent[3].transform); gotuoguan.transform.localPosition = new Vector3(gotuoguan.transform.localPosition.x, gotuoguan.transform.localPosition.y, 0); gotuoguan.transform.localScale = Vector3.one; gotuoguan.transform.Find("Label").GetComponent <Text>().text = MahjongLobby_AH.UIMainView.Instance.CreatRoomMessagePanel.lTuoGuan[i]; gotuoguan.GetComponent <Toggle>().interactable = false; int LateTime = 0; if (i != 0) { string str = MahjongLobby_AH.UIMainView.Instance.CreatRoomMessagePanel.lTuoGuan[i]; str = str.Substring(0, MahjongLobby_AH.UIMainView.Instance.CreatRoomMessagePanel.lTuoGuan[i].Length - 1); LateTime = (Convert.ToInt32(str) / 60); } if (cd.roomMessage_[5] == LateTime) { gotuoguan.GetComponent <Toggle>().isOn = true; } else { gotuoguan.GetComponent <Toggle>().isOn = false; } } } else { TuoGuan.SetActive(false); m_GameRule.enabled = false; } if (MahjongCommonMethod.Instance.ReadColumnValue(cd.roomMessage_, 2, 39) == 2) { RuleParent[4].transform.GetChild(0).GetComponent <Toggle>().isOn = true; RuleParent[4].transform.GetChild(1).GetComponent <Toggle>().isOn = false; } else if (MahjongCommonMethod.Instance.ReadColumnValue(cd.roomMessage_, 2, 39) <= 1) { RuleParent[4].transform.GetChild(0).GetComponent <Toggle>().isOn = false; RuleParent[4].transform.GetChild(1).GetComponent <Toggle>().isOn = true; } if (RuleParent[0].GetComponentsInChildren <Transform>().Length < 1) { RuleParent[0].transform.parent.gameObject.SetActive(false); } else { RuleParent[0].transform.parent.gameObject.SetActive(true); } if (PlayGoldModth.activeSelf) { m_GameRule.enabled = true; } #endregion if (!mcm._dicMethodCardType.ContainsKey(index)) { RuleParent_.SetActive(false); return; } RuleParent_.SetActive(true); //该玩法有多个规则可以实现 for (int i = 0; i < mcm._dicMethodCardType[index].Count; i++) { GameObject go = null; //如果该玩法为多选 if (mcm._dicmethodToCardType[index][i].Choice == 2) { go = Instantiate(Resources.Load <GameObject>("Lobby/PlayerMethodPanel/MultiChoiceBtn")); go.name = "MultiChoiceBtn"; if (mcm._dicmethodToCardType[index][i].Hierarchy == 1) { num_MultiChoiceBtn++; } else { RuleParent[mcm._dicmethodToCardType[index][i].Hierarchy - 1].GetComponent <GridLayoutGroup>().padding.left = 65; go.transform.Find("Label").transform.localPosition += new Vector3(20, 0, 0); } } else { go = Instantiate(Resources.Load <GameObject>("Lobby/PlayerMethodPanel/OnlyOneChoice")); go.GetComponent <Toggle>().group = RuleParent[mcm._dicmethodToCardType[index][i].Hierarchy - 1].GetComponent <ToggleGroup>(); go.name = "OnlyOneChoice"; } bool status = mcm.JudgeIsShow(mcm._dicmethodToCardType[index][i].RuleId); if (status) { for (int k = 0; k < mcm._dicMethodCardType[index].Count; k++) { if (mcm._dicMethodCardType[index][i].ID == mcm._dicmethodToCardType[index][i].RuleId) { SelectContent.Add(mcm._dicMethodCardType[index][i].notes); break; } } } go.transform.SetParent(RuleParent[mcm._dicmethodToCardType[index][i].Hierarchy - 1].transform); go.transform.localPosition = new Vector3(go.transform.localPosition.x, go.transform.localPosition.y, 0); go.transform.localScale = Vector3.one; go.transform.Find("Label").GetComponent <Text>().text = mcm._dicMethodCardType[index][i].card_type; go.GetComponent <Toggle>().interactable = false; if (status) { go.transform.Find("Label").GetComponent <Text>().color = new Color(1, 0, 0, 1);//红色 选中为红色 go.GetComponent <Toggle>().isOn = true; } } if (num_MultiChoiceBtn <= 4) { RuleParent[0].GetComponentInParent <LayoutElement>().minHeight = 70f; } else { RuleParent[0].GetComponentInParent <LayoutElement>().minHeight = 120f; } //if (num_OnlyOneChoice == 0) //{ // RuleParent[1].SetActive(false); // RuleParent[2].SetActive(false); //} //else //{ // RuleParent[1].SetActive(true); // RuleParent[2].SetActive(true); //} RuleParent_.GetComponent <LayoutElement>().minHeight = 170f + (int)((num_MultiChoiceBtn) / 4f - 0.5f) * 50f; }
/// <summary> /// 产生玩法数量的预置体 /// </summary> /// <param name="index">玩法id</param> /// <param name="ChoiceIndex">玩家选择的下标</param> void SpwanPayNum(int index) { int ChoiceIndex = -1; MahjongCommonMethod mcm = MahjongCommonMethod.Instance; PlayerPlayingPanelData pppd = GameData.Instance.PlayerPlayingPanelData; //玩法局或圈的数量 int[] sum = new int[5]; //玩法数量对应支付的房卡数量 int[] pay = new int[5]; //获取对应的游戏局或者圈的数量 if (mcm._dicMethodConfig[index].sum.Contains("|")) { string[] str_0 = mcm._dicMethodConfig[index].sum.Split('|')[0].Split('_'); string[] str_1 = mcm._dicMethodConfig[index].sum.Split('|')[1].Split('_'); for (int i = 0; i < 3; i++) { sum[i] = Convert.ToInt16(str_0[i]); } for (int i = 0; i < 2; i++) { sum[i + 3] = Convert.ToInt16(str_1[i]); } } else { string[] str_0 = mcm._dicMethodConfig[index].sum.Split('_'); for (int i = 0; i < 3; i++) { if (i < str_0.Length) { sum[i] = Convert.ToInt16(str_0[i]); } else { sum[i] = 0; } } sum[3] = 0; sum[4] = 0; } //获取玩家对应的支付数量 if (mcm._dicMethodConfig[index].pay.Contains("|")) { string[] str_0 = mcm._dicMethodConfig[index].pay.Split('|')[0].Split('_'); string[] str_1 = mcm._dicMethodConfig[index].pay.Split('|')[1].Split('_'); for (int i = 0; i < 3; i++) { pay[i] = Convert.ToInt16(str_0[i]); } for (int i = 0; i < 2; i++) { pay[i + 3] = Convert.ToInt16(str_1[i]); } } else { string[] str_0 = mcm._dicMethodConfig[index].pay.Split('_'); for (int i = 0; i < 3; i++) { if (i < str_0.Length) { pay[i] = Convert.ToInt16(str_0[i]); } else { pay[i] = 0; } } pay[3] = 0; pay[4] = 0; } //if (index == 17) //{ // sum[3] = 4; pay[3] = pay[0]; // sum[4] = 8; pay[4] = pay[1]; // sum[5] = 12; pay[5] = pay[2]; //} //int addChoiceIndex = 0; if (index == 17) { if (pppd.playingMethodConf.byBillingMode == 2) { sum[0] = 4; sum[1] = 8; sum[2] = 12; //addChoiceIndex = 3; } } int count = 0; //根据付费数量,判断出玩家的信息 for (int i = 0; i < 5; i++) { if (index == 2 && pppd.playingMethodConf.byBillingPrice == pay[i] && pppd.playingMethodConf.byBillingMode == 2) { ChoiceIndex = i; //pppd.playingMethodConf.byBillingMode = 1; } else if (pppd.playingMethodConf.byBillingNumber == sum[i] && pppd.playingMethodConf.byBillingPrice == pay[i]) { ChoiceIndex = i; } } MahjongLobby_AH.Data.CreatRoomMessagePanelData cd = MahjongLobby_AH.GameData.Instance.CreatRoomMessagePanelData; if (MahjongCommonMethod.Instance.ReadColumnValue(cd.roomMessage_, 2, 39) <= 1) { for (int pay_index = 0; pay_index < pay.Length; pay_index++) { if (pay[pay_index] != 0) { pay[pay_index] = pay[pay_index] / 4; Debug.LogError(pay[pay_index]); } } } //删除自己的之前的房间规则信息 CreatRoomChoiceMethod[] method = PayNumParent.Find("GameNumbers").GetComponentsInChildren <CreatRoomChoiceMethod>(); if (method.Length > 0) { for (int i = 0; i < method.Length; i++) { Destroy(method[i].gameObject); } } //产生对应的玩法数据 for (int i = 0; i < sum.Length; i++) { if (sum[i] == 0) { continue; } GameObject go = Instantiate(Resources.Load <GameObject>("Lobby/PlayerMethodPanel/CreatRoomChoiceMethod")); go.name = "CreatRoomChoiceMethod"; go.transform.SetParent(PayNumParent.Find("GameNumbers")); go.transform.localPosition = new Vector3(go.transform.localPosition.x, go.transform.localPosition.y, 0); go.transform.localScale = Vector3.one; if (i == ChoiceIndex) { go.transform.GetComponent <Toggle>().isOn = true; } else { go.transform.GetComponent <Toggle>().isOn = false; } go.transform.GetComponent <Toggle>().interactable = false; CreatRoomChoiceMethod crcm = go.GetComponent <CreatRoomChoiceMethod>(); crcm.type = pppd.playingMethodConf.byBillingMode; crcm.num = sum[i]; crcm.pay = pay[i]; crcm.UpdateShow(); count++; } if (pppd.playingMethodConf.byBillingMode == 1) { PayNumParent.GetChild(1).GetComponent <Text>().text = "圈数:"; } else if (pppd.playingMethodConf.byBillingMode == 2) { PayNumParent.GetChild(1).GetComponent <Text>().text = "局数:"; } else if (pppd.playingMethodConf.byBillingMode == 3) { PayNumParent.GetChild(1).GetComponent <Text>().text = "分数:"; } PayNumParent.GetComponent <LayoutElement>().minHeight = 60f; //PayNumParent.GetComponent<LayoutElement>().minHeight = 60f + ((int)(count / 3f + 0.5f) - 1f) * 45; }
/// <summary> /// 产生玩法数量的预置体 /// </summary> /// <param name="index"></param> void SpwanPayNum(int index) { if (MethodParent.GetComponentsInChildren <Transform>().Length > 1) { return; } int AllCol = 0; // Debug.Log("玩法" + index); anhui.MahjongCommonMethod mcm = anhui.MahjongCommonMethod.Instance; PlayerPlayingPanelData pppd = GameData.Instance.PlayerPlayingPanelData; MahjongLobby_AH.Data.CreatRoomMessagePanelData cd = MahjongLobby_AH.GameData.Instance.CreatRoomMessagePanelData; #region 分数 GameObject fenshu = Instantiate(Method) as GameObject; fenshu.transform.SetParent(MethodParent.transform); fenshu.transform.localPosition = Vector3.zero; fenshu.transform.localRotation = Quaternion.identity; fenshu.transform.localScale = Vector3.one; MainViewGameRulePlayMethod method_fenshu = fenshu.GetComponent <MainViewGameRulePlayMethod>(); method_fenshu.transform.GetChild(1).GetComponent <GridLayoutGroup>().cellSize = new Vector2(66.0f, method_fenshu.transform.GetChild(1).GetComponent <GridLayoutGroup>().cellSize.y); method_fenshu.Name.text = "分数:"; //分数 GameObject method_fenshu_Select = Instantiate(method_fenshu.GameRuleName) as GameObject; method_fenshu_Select.transform.SetParent(method_fenshu.Parent); method_fenshu_Select.transform.localPosition = Vector3.zero; method_fenshu_Select.transform.localRotation = Quaternion.identity; method_fenshu_Select.transform.localScale = Vector3.one; string str_method_fenshu_Select = ""; if (pppd.playingMethodConf.byBillingMode == 1) { str_method_fenshu_Select = pppd.playingMethodConf.byBillingNumber + "圈"; } else if (pppd.playingMethodConf.byBillingMode == 2) { str_method_fenshu_Select = pppd.playingMethodConf.byBillingNumber + "局"; } else if (pppd.playingMethodConf.byBillingMode == 3) { str_method_fenshu_Select = pppd.playingMethodConf.byBillingNumber + "分"; } //Debug.LogError("局"+pppd.playingMethodConf.byBillingNumber); method_fenshu_Select.transform.GetChild(0).gameObject.SetActive(false); method_fenshu_Select.GetComponentsInChildren <Text>()[0].text = str_method_fenshu_Select; //需要的金币 GameObject method_fenshu_Gold = Instantiate(method_fenshu.GameRuleGold) as GameObject; method_fenshu_Gold.transform.SetParent(method_fenshu.Parent); method_fenshu_Gold.transform.localPosition = Vector3.zero; method_fenshu_Gold.transform.localRotation = Quaternion.identity; method_fenshu_Gold.transform.localScale = Vector3.one; method_fenshu_Gold.GetComponentsInChildren <Text>()[0].text = "X" + pppd.playingMethodConf.byBillingPrice.ToString(); AllCol++; #endregion #region 支付方式 GameObject zhifufangshi = Instantiate(Method) as GameObject; zhifufangshi.transform.SetParent(MethodParent.transform); zhifufangshi.transform.localPosition = Vector3.zero; zhifufangshi.transform.localRotation = Quaternion.identity; zhifufangshi.transform.localScale = Vector3.one; MainViewGameRulePlayMethod method_zhifufangshi = zhifufangshi.GetComponent <MainViewGameRulePlayMethod>(); method_zhifufangshi.Name.text = "房费:"; //支付方式 GameObject method_zhifufangshi_Select = Instantiate(method_zhifufangshi.GameRuleName) as GameObject; method_zhifufangshi_Select.transform.SetParent(method_zhifufangshi.Parent); method_zhifufangshi_Select.transform.localPosition = Vector3.zero; method_zhifufangshi_Select.transform.localRotation = Quaternion.identity; method_zhifufangshi_Select.transform.localScale = Vector3.one; method_zhifufangshi_Select.transform.GetChild(0).gameObject.SetActive(false); if (anhui.MahjongCommonMethod.Instance.ReadColumnValue(cd.roomMessage_, 2, 39) <= 1) { method_zhifufangshi_Select.GetComponentsInChildren <Text>()[0].text = "四家支付"; } else if (anhui.MahjongCommonMethod.Instance.ReadColumnValue(cd.roomMessage_, 2, 39) == 2) { method_zhifufangshi_Select.GetComponentsInChildren <Text>()[0].text = "房主支付"; } AllCol++; #endregion #region 玩法 if (mcm._dicMethodCardType.ContainsKey(index)) { int count = 0; int count_jibu = 5; GameObject wanfa = Instantiate(Method) as GameObject; wanfa.transform.SetParent(MethodParent.transform); wanfa.transform.localPosition = Vector3.zero; wanfa.transform.localRotation = Quaternion.identity; wanfa.transform.localScale = Vector3.one; MainViewGameRulePlayMethod method_wanfa = wanfa.GetComponent <MainViewGameRulePlayMethod>(); method_wanfa.transform.GetChild(1).GetComponent <GridLayoutGroup>().padding.left = 8; method_wanfa.Name.text = "玩法:"; AllCol++; for (int i = 0; i < mcm._dicMethodCardType[index].Count; i++) { // Debug.LogWarning("规则:" + mcm._dicmethodToCardType[index][i].RuleId); if (mcm.JudgeIsShow(mcm._dicmethodToCardType[index][i].RuleId)) { string name = mcm._cardType_[mcm._dicmethodToCardType[index][i].RuleId].card_type; // Debug.Log(mcm._cardType_[mcm._dicmethodToCardType[index][i].RuleId].card_type); GameObject method_wanfa_Select = Instantiate(method_wanfa.GameRuleName) as GameObject; method_wanfa_Select.transform.SetParent(method_wanfa.Parent); method_wanfa_Select.transform.localPosition = Vector3.zero; method_wanfa_Select.transform.localRotation = Quaternion.identity; method_wanfa_Select.transform.localScale = Vector3.one; method_wanfa_Select.GetComponentsInChildren <Text>()[0].text = name; count++; if (count == count_jibu) { GameObject wanfa_1 = Instantiate(Method) as GameObject; wanfa_1.transform.SetParent(MethodParent.transform); wanfa_1.transform.localPosition = Vector3.zero; wanfa_1.transform.localRotation = Quaternion.identity; wanfa_1.transform.localScale = Vector3.one; MainViewGameRulePlayMethod method_wanfa_1 = wanfa_1.GetComponent <MainViewGameRulePlayMethod>(); method_wanfa_1.Name.text = ""; AllCol++; count_jibu += 4; } } } } #endregion #region 托管 if (cd.roomMessage_[5] > 0) { GameObject tuoguan = Instantiate(Method) as GameObject; tuoguan.transform.SetParent(MethodParent.transform); tuoguan.transform.localPosition = Vector3.zero; tuoguan.transform.localRotation = Quaternion.identity; tuoguan.transform.localScale = Vector3.one; MainViewGameRulePlayMethod method_tuoguan = tuoguan.GetComponent <MainViewGameRulePlayMethod>(); method_tuoguan.Name.text = "托管:"; //托管 GameObject method_tuoguan_Select = Instantiate(method_tuoguan.GameRuleName) as GameObject; method_tuoguan_Select.transform.SetParent(method_tuoguan.Parent); method_tuoguan_Select.transform.localPosition = Vector3.zero; method_tuoguan_Select.transform.localRotation = Quaternion.identity; method_tuoguan_Select.transform.localScale = Vector3.one; method_tuoguan_Select.transform.GetChild(0).gameObject.SetActive(false); method_tuoguan_Select.GetComponentsInChildren <Text>()[0].text = (cd.roomMessage_[5] * 60) + "秒"; AllCol++; } #endregion if (AllCol >= 4) { int leng = 20; leng = ((AllCol - 4) + 1) * 25; //背景框面板 m_imMoveBGLeft.rectTransform.offsetMin = new Vector2(m_imMoveBGLeft.rectTransform.offsetMin.x, m_imMoveBGLeft.rectTransform.offsetMin.y - leng); m_imMoveBGLeft.transform.localPosition = new Vector3(m_imMoveBGLeft.transform.localPosition.x, 0); m_imMoveBGRight.rectTransform.offsetMin = new Vector2(m_imMoveBGRight.rectTransform.offsetMin.x, m_imMoveBGRight.rectTransform.offsetMin.y - leng); m_imMoveBGRight.transform.localPosition = new Vector3(m_imMoveBGRight.transform.localPosition.x, 0); //其他面板 m_gAllMoveUp.transform.localPosition = new Vector3(m_gAllMoveUp.transform.localPosition.x, leng, m_gAllMoveUp.transform.localPosition.z); m_gAllMoveDown.transform.localPosition = new Vector3(m_gAllMoveUp.transform.localPosition.x, -(leng - leng / 4), m_gAllMoveUp.transform.localPosition.z); } }