Exemple #1
0
 private void OnRespone(object obj)
 {
     if (obj == null)
     {
         return;
     }
     if (obj is SCTitleResponse)
     {
         SCTitleResponse res = (SCTitleResponse)obj;
         if (res.Status == null)
         {
             ////后面优化吧
             List <ConfTitle> titleArray = CompareTitle(res);
             //List<ConfTitle> titleArray = ConfTitle.array;
             //m_grid_con.Clear();
             m_grid_con.EnsureSize <TitleComponent>(titleArray.Count);
             for (int i = 0; i < titleArray.Count; i++)
             {
                 TitleComponent title = m_grid_con.GetChild <TitleComponent>(i);
                 title.Visible = true;
                 bool     isLock   = true;
                 TitleMsg titleMsg = null;
                 bool     isChoose = false;
                 for (int j = 0; j < res.Titles.Count; j++)
                 {
                     if (titleArray[i].id == res.Titles[j].TitleId)
                     {
                         isLock   = false;
                         titleMsg = res.Titles[j];
                         if (titleMsg.TitleId == m_chooseID)
                         {
                             isChoose      = true;
                             m_curTitleMsg = title;
                         }
                         break;
                     }
                 }
                 title.SetData(titleArray[i], titleMsg, isChoose, isLock);
             }
         }
     }
 }
        private void OnRefreshTitle(object msg)
        {
            if (msg is SCTitleGetResponse)
            {
                SCTitleGetResponse res = (SCTitleGetResponse)msg;
                if (res.Status == null)
                {
                    if (res.Title != null)
                    {
                        GlobalInfo.MY_PLAYER_INFO.TitleID = res.Title.TitleId;
                    }
                }
            }
            else if (msg is SCTitleActiveResponse)
            {
                SCTitleActiveResponse res = (SCTitleActiveResponse)msg;

                if (res.Status == null)
                {
                    GlobalInfo.MY_PLAYER_INFO.TitleID = res.Title.TitleId;
                }
            }
            else if (msg is SCTitleResponse)
            {
                if (0L == GlobalInfo.MY_PLAYER_INFO.TitleID)
                {
                    SCTitleResponse res = (SCTitleResponse)msg;
                    if (res.Status == null)
                    {
                        foreach (var title in res.Titles)
                        {
                            if (title.Active)
                            {
                                GlobalInfo.MY_PLAYER_INFO.TitleID = title.TitleId;
                                break;
                            }
                        }
                    }
                }
            }
        }
Exemple #3
0
        private List <ConfTitle> CompareTitle(SCTitleResponse res)
        {
            List <TitleMsg> titlemsgs = new List <TitleMsg>(res.Titles);

            titlemsgs.Sort(CompareTitle);
            List <ConfTitle> titles    = ConfTitle.array;
            List <ConfTitle> newTitles = new List <ConfTitle>();

            for (int i = 0; i < titlemsgs.Count; i++)
            {
                ConfTitle title = ConfTitle.Get(titlemsgs[i].TitleId);
                if (title == null)
                {
                    Debug.LogError("title id is none :" + titlemsgs[i].TitleId);
                    continue;
                }
                newTitles.Add(title);
            }
            for (int i = 0; i < titles.Count; i++)
            {
                bool hasTitle = false;
                for (int j = 0; j < titlemsgs.Count; j++)
                {
                    if (titlemsgs[j].TitleId == titles[i].id)
                    {
                        hasTitle = true;
                        break;
                    }
                }
                if (!hasTitle)
                {
                    newTitles.Add(titles[i]);
                }
            }
            return(newTitles);
        }