示例#1
0
        /// <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="MethodId">玩法id</param>
        void SpwanPayNum(int MethodId)
        {
            PlayBackData pbd         = MahjongLobby_AH.GameData.Instance.PlayBackData;
            int          ChoiceIndex = -1;

            anhui.MahjongCommonMethod mcm = anhui.MahjongCommonMethod.Instance;

            //玩法局或圈的数量
            int[] sum = new int[5];
            //玩法数量对应支付的房卡数量
            int[] pay = new int[5];

            //获取对应的游戏局或者圈的数量
            if (mcm._dicMethodConfig[MethodId].sum.Contains("|"))
            {
                string[] str_0 = mcm._dicMethodConfig[MethodId].sum.Split('|')[0].Split('_');
                string[] str_1 = mcm._dicMethodConfig[MethodId].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[MethodId].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[MethodId].pay.Contains("|"))
            {
                string[] str_0 = mcm._dicMethodConfig[MethodId].pay.Split('|')[0].Split('_');
                string[] str_1 = mcm._dicMethodConfig[MethodId].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[MethodId].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;
            }

            int count = 0;

            //根据付费数量,判断出玩家的信息
            for (int i = 0; i < 5; i++)
            {
                if (pbd.playingMethodConf_2.byBillingNumber == sum[i] && pbd.playingMethodConf_2.byBillingPrice == pay[i])
                {
                    ChoiceIndex = i;
                }
            }

            //删除自己的之前的房间规则信息
            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 = pbd.playingMethodConf_2.byBillingMode;
                crcm.num  = sum[i];
                crcm.pay  = pay[i];
                crcm.UpdateShow();
                count++;
            }

            PayNumParent.GetComponent <LayoutElement>().minHeight = 60f + ((int)(count / 3f + 0.5f) - 1f) * 45;
        }