Ejemplo n.º 1
0
        private void UpdateServerList(List <gamelogic_district_info> groupList)
        {
            int nCount = ServerList.transform.childCount;

            for (int i = nCount - 1; i >= 0; --i)
            {
                Transform childTrans = ServerList.transform.GetChild(i);
                if (childTrans)
                {
                    GameObject go = childTrans.gameObject;
                    // 销毁obj
                    ResNode.DestroyRes(ref go);
                }
            }

            for (int i = 0; i < groupList.Count; i++)
            {
                GameObject serverGo = ResNode.InstantiateRes(DefaultServerItem);
                if (serverGo != null)
                {
                    serverGo.transform.SetParent(ServerList.transform, false);
                    serverGo.GetComponent <UButtonGroupItem>().Group = ServerList;
                    serverGo.SetActive(true);

                    Text btnLabel = serverGo.GetComponentInChildren <Text>();
                    if (btnLabel)
                    {
                        btnLabel.text = groupList[i].szName;
                    }

                    //正常
                    if (groupList[i].nState < 2)
                    {
                        Transform icon_Green = serverGo.transform.FindChild("Icon_Green");
                        if (icon_Green)
                        {
                            icon_Green.gameObject.SetActive(true);
                        }
                    }
                    else//爆满
                    {
                        Transform icon_Red = serverGo.transform.FindChild("Icon_Red");
                        if (icon_Red)
                        {
                            icon_Red.gameObject.SetActive(true);
                        }
                    }

                    DistrictInfo districtInfo = serverGo.GetComponent <DistrictInfo>();
                    if (districtInfo != null)
                    {
                        districtInfo.SetData(i, groupList[i].nGroup, groupList[i].nDistrict, groupList[i].nServer);
                    }
                }
            }
        }
Ejemplo n.º 2
0
        public void UpdateLastEnterDistrictList()
        {
            int nCount = LastEnterServerList.transform.childCount;

            for (int i = nCount - 1; i >= 0; --i)
            {
                Transform childTrans = LastEnterServerList.transform.GetChild(i);
                if (childTrans)
                {
                    GameObject go = childTrans.gameObject;
                    // 销毁obj
                    ResNode.DestroyRes(ref go);
                }
            }

            m_lastEnterDistrictList = DataCenter.LogicDataCenter.districtListDataManger.LastEnterDistrictInfoList;

            if (m_lastEnterDistrictList == null || m_lastEnterDistrictList.Count < 1)
            {
                return;
            }

            for (int i = 0; i < m_lastEnterDistrictList.Count; i++)
            {
                //最多列5个
                if (i > 5)
                {
                    break;
                }

                GameObject serverGo = ResNode.InstantiateRes(DefaultLastServerItem);
                if (serverGo != null)
                {
                    serverGo.transform.SetParent(LastEnterServerList.transform, false);
                    serverGo.GetComponent <UButtonGroupItem>().Group = LastEnterServerList;
                    serverGo.SetActive(true);

                    Text btnLabel = serverGo.GetComponentInChildren <Text>();
                    if (btnLabel)
                    {
                        btnLabel.text = m_lastEnterDistrictList[i].szName;
                    }

                    DistrictInfo districtInfo = serverGo.GetComponent <DistrictInfo>();
                    if (districtInfo != null)
                    {
                        districtInfo.SetData(i, m_lastEnterDistrictList[i].nGroup, m_lastEnterDistrictList[i].nDistrict, m_lastEnterDistrictList[i].nServer);
                    }
                }
            }
        }