Ejemplo n.º 1
0
 private void CreateTeamInfoItems()
 {
     //\read world team info
     mItemNum = 3;
     if (mItemNum > TeamInfoItemList.Count)
     {
         int addNum = mItemNum - TeamInfoItemList.Count;
         for (int i = 0; i < addNum; i++)
         {
             GameObject   obj  = ((GameObject)Instantiate(ATeamInfoItem.gameObject));
             TeamInfoItem item = obj.GetComponent <TeamInfoItem>();
             item.InitInfo(i, MyUIGrid.transform);
             TeamInfoItemList.Add(item);
         }
         //TeamInfoItemList.ApplyAllItem(p => p.UpdateInfo());
     }
     else
     {
         int num = 0;
         TeamInfoItemList.ApplyAllItem(p =>
         {
             if (num < mItemNum)
             {
                 //p.UpdateInfo();
             }
             else
             {
                 p.gameObject.SetActive(false);
             }
             num++;
         });
     }
     //排序
     MyUIGrid.repositionNow = true;
 }
Ejemplo n.º 2
0
        public void CreateTeamInfoItems(SMsgTeamNum_SC sMsgTeamNum)
        {
            mItemNum = sMsgTeamNum.wTeamNum;    //队伍数量

            if (mItemNum <= 0)
            {
                NoneTeamTip.SetActive(true);
            }
            else
            {
                NoneTeamTip.SetActive(false);
            }

            /*
             * if (mItemNum > TeamInfoItemList.Count)
             * {
             *  int addNum = mItemNum - TeamInfoItemList.Count;
             *  for (int i = 0; i < addNum; i++)
             *  {
             *      GameObject obj = ((GameObject)Instantiate(ATeamInfoItem.gameObject));
             *      TeamInfoItem item = obj.GetComponent<TeamInfoItem>();
             *      item.InitInfo(i, MyUIGrid.transform);
             *      TeamInfoItemList.Add(item);
             *
             *      //\
             *      item.UpdateInfo(sMsgTeamNum.SMsgTeamProps[i]);
             *  }
             *  //TeamInfoItemList.ApplyAllItem(p => p.UpdateInfo());
             * }
             * else
             * {
             *  int num = 0;
             *  TeamInfoItemList.ApplyAllItem(p =>
             *  {
             *      if (num < mItemNum)
             *      {
             *          //\
             *          p.UpdateInfo(sMsgTeamNum.SMsgTeamProps[num]);
             *      }
             *      else
             *      {
             *          p.Close();
             *      }
             *      num++;
             *  });
             * }
             * //排列
             * MyUIGrid.repositionNow = true;
             *
             */
            #region new page

            /*
             * if (mItemNum > TeamInfoItemList.Count)
             * {
             *  int addNum = mItemNum - TeamInfoItemList.Count;
             *  for (int i = 0; i < addNum; i++)
             *  {
             *      GameObject obj = ((GameObject)Instantiate(ATeamInfoItem.gameObject));
             *      TeamInfoItem item = obj.GetComponent<TeamInfoItem>();
             *      item.InitInfo(i, ItemPageManager_Team.transform);
             *      TeamInfoItemList.Add(item);
             *      item.UpdateInfo(sMsgTeamNum.SMsgTeamProps[i]);
             *  }
             * }
             * else
             * {
             *  int num = 0;
             *  TeamInfoItemList.ApplyAllItem(p =>
             *  {
             *      if (num < mItemNum)
             *      {
             *          p.UpdateInfo(sMsgTeamNum.SMsgTeamProps[num]);
             *      }
             *      else
             *      {
             *          p.Close();
             *      }
             *      num++;
             *  });
             * }
             */
            #endregion

            TeamInfoItemList.ApplyAllItem(p =>
            {
                Destroy(p.gameObject);
            });
            TeamInfoItemList.Clear();
            for (int i = 0; i < mItemNum; i++)
            {
                GameObject   obj  = ((GameObject)Instantiate(ATeamInfoItem.gameObject));
                TeamInfoItem item = obj.GetComponent <TeamInfoItem>();
                item.InitInfo(i, ItemPageManager_Team.transform);
                TeamInfoItemList.Add(item);
                item.UpdateInfo(sMsgTeamNum.SMsgTeamProps[i]);
            }

            mItemNum = Mathf.Clamp(mItemNum, 1, 100);
            ItemPageManager_Team.InitPager(mItemNum, 1, 0);
        }