Example #1
0
 private void OnResponse(object obj)
 {
     if (obj is SCNoticeListResponse)
     {
         //Debug.Log("enter SCNoticeListResponse==");
         SCNoticeListResponse res = obj as SCNoticeListResponse;
         OnInitPanel(res);
         //Debug.Log("enter SCNoticeListResponse over ==" + res.Notices.Count);
     }
 }
 private void OnScResponse(object s)
 {
     if (s is SCNoticeListResponse && Is_login)
     {
         SCNoticeListResponse res = (SCNoticeListResponse)s;
         if (res != null && res.Notices != null)
         {
             LocalDataManager.Instance.HasNewNotic(res.Notices);
         }
     }
 }
Example #3
0
        private void OnInitPanel(SCNoticeListResponse res)
        {
            List <NoticeInfo> imgInfos  = new List <NoticeInfo>();
            List <NoticeInfo> textInfos = new List <NoticeInfo>();

            for (int i = 0; i < res.Notices.Count; i++)
            {
                NoticeInfo      notice = res.Notices[i];
                System.DateTime dt     = CommonTools.TimeStampToDateTime(notice.EndTime * 10000);
                if (notice.LevelLimit != 0 || System.DateTime.Now > dt)
                {
                    continue;
                }
                if (notice.Type == 1)
                {
                    //图片
                    imgInfos.Add(notice);
                    //imgInfos.Add(notice);
                }
                else if (notice.Type == 2)
                {
                    //文字
                    textInfos.Add(notice);
                }
            }
            textInfos.Sort((x, y) => - CompareNoticeTex(x, y));
            int imgCount = Mathf.CeilToInt(imgInfos.Count / 2f);

            m_imageScroll.SetData(imgInfos);
            //m_imageScroll.SetData(imgInfos);

            //m_imgRoot_con.EnsureSize<NoticImgPanel>(imgCount);
            //for (int i = 0; i < imgCount; i++)
            //{
            //    NoticImgPanel imgPanel = m_imgRoot_con.GetChild<NoticImgPanel>(i);
            //    if (i * 2 + 1 >= imgInfos.Count)
            //    {
            //        imgPanel.setData(imgInfos[i * 2], null, i % 2 == 0);
            //    }
            //    else
            //    {
            //        imgPanel.setData(imgInfos[i * 2], imgInfos[i * 2 + 1], i % 2 == 0);
            //    }
            //}

            m_textRoot_con.EnsureSize <NoticTextComponent>(textInfos.Count);
            for (int i = 0; i < textInfos.Count; i++)
            {
                NoticTextComponent textPanel = m_textRoot_con.GetChild <NoticTextComponent>(i);
                textPanel.SetData(textInfos[i]);
                textPanel.Visible = true;
            }
        }