예제 #1
0
    public void SelectClick(GameObject obj)
    {
        foreach (PVPBattleItem CI in childItems)
        {
            CI.gameObject.SetActive(false);
        }

        PVPBattleItem item = obj.GetComponent <PVPBattleItem>();

        if (channelDic.ContainsKey(item.ItemID))
        {
            List <string> channels = channelDic[item.ItemID];

            for (int i = 0; i < channels.Count; i++)
            {
                string[] channelInfo = channels[i].Split(',');
                if (i >= gridChanel1.transform.childCount)
                {
                    GameObject objBtn = (GameObject)Instantiate(btnChannelMap);
                    objBtn.transform.parent     = gridChanel1.transform;
                    objBtn.transform.localScale = new Vector3(1, 1, 1);
                    objBtn.SetActive(false);
                    UIButtonMessage btnMessage = objBtn.GetComponent <UIButtonMessage>();
                    btnMessage.target       = this.gameObject;
                    btnMessage.functionName = "BtnToMap";
                    PVPBattleItem tempBtn = objBtn.GetComponent <PVPBattleItem>();
                    tempBtn.SetBattleName(string.Format("{0}{1}{2}", yt.Rows[0]["MapName"].YuanColumnText, (i + 1).ToString(), StaticLoc.Loc.Get("info1153")));
//					Debug.Log("ran=============================="+channelInfo[1].ToString());
                    if (int.Parse(channelInfo[1]) == 1)
                    {
                        tempBtn.SetBattleLblbusy(StaticLoc.Loc.Get("info1160"));
                    }

                    if (int.Parse(channelInfo[1]) == 0)
                    {
                        tempBtn.SetBattleLblbusy(StaticLoc.Loc.Get("info1161"));
                    }

                    tempBtn.ItemID = int.Parse(channelInfo[0]);
                    childItems.Add(tempBtn);
                }

                childItems[i].ItemID = int.Parse(channelInfo[0]);
                childItems[i].gameObject.SetActive(true);
                if (PlayerUtil.mapInstanceID == childItems[i].ItemID)
                {
                    LblMyChannel.text = string.Format("{0}{1}{2}{3}", StaticLoc.Loc.Get("info1162"), yt.Rows[0]["MapName"].YuanColumnText, (i + 1).ToString(), StaticLoc.Loc.Get("info1153"));
                }

                if (LblMyChannelOther)
                {
                    LblMyChannelOther.text = LblMyChannel.text;
                }
            }
            gridChanel1.repositionNow = true;
        }
    }
예제 #2
0
    public void ShowSelectChannel(Dictionary <int, bool> selectchannel)
    {
        index = 0;
        int           count           = 0;
        List <string> channelInfoList = new List <string>();

        foreach (KeyValuePair <int, bool> kvp in selectchannel)
        {
            int    val     = kvp.Value ? 1 : 0;
            string tempStr = string.Format("{0},{1}", kvp.Key, val);
            channelInfoList.Add(tempStr);
            count++;

            if (count >= size)
            {
                channelDic.Add(index, channelInfoList);
                index++;
                count           = 0;
                channelInfoList = new List <string>();
            }
        }

        if (selectchannel.Count < size)
        {
            channelDic.Add(0, channelInfoList);
        }

        if (channelDic.Count >= 0)
        {
            foreach (int key in channelDic.Keys)
            {
                GameObject objBtn = (GameObject)Instantiate(btnChannel);
                objBtn.transform.parent     = gridChanel.transform;
                objBtn.transform.localScale = new Vector3(1, 1, 1);
                UIButtonMessage btnMessage = objBtn.GetComponent <UIButtonMessage>();
                btnMessage.target       = this.gameObject;
                btnMessage.functionName = "SelectClick";
                PVPBattleItem tempBtn = objBtn.GetComponent <PVPBattleItem>();
                tempBtn.SetBattleName(string.Format("{0}{1}{2}", yt.Rows[0]["MapName"].YuanColumnText, (key + 1).ToString(), StaticLoc.Loc.Get("info1154")));
                tempBtn.ItemID = key;

                Transform firstTran = this.gridChanel.GetChild(0);
                firstTran.GetComponent <UIToggle>().value = true;
                SelectClick(firstTran.gameObject);
            }
        }
        gridChanel.repositionNow = true;
    }