Example #1
0
        public static bool CheckData(string reply, out LoginNoticeData data)
        {
            data = new LoginNoticeData();

            data.FromJson(reply);
            if (data.result != 1)
            {
                GameDebug.LogError("解析公告失败: " + reply);
                return(false);
            }

            return(true);
        }
Example #2
0
        private void ShowNoticePanel(LoginNoticeData data, bool isFromServer = false)
        {
            if (AuditManager.Instance.AuditAndIOS() && SDKHelper.GetSwitchModel())
            {
                return;
            }

            GameDebug.Log("弹出游戏公告窗口");
            UIManager.Instance.ShowWindow("UILoginNoticeWindow", data, isFromServer);

            //if (string.IsNullOrEmpty(data.content) == false)
            //{

            //}
        }
        protected override void ResetUI()
        {
            base.ResetUI();
            UIManager.Instance.ShowWaitScreen(false);

            this.data      = this.ShowParam[0] as LoginNoticeData;
            fromServerList = (bool)this.ShowParam[1];
            Debug.Log("from server list " + fromServerList);

            //PlayerPrefs.SetInt(LoginNoticeData.LOGIN_ID_KEY, data.id);


            this.FreeTemplateInstance(TEMPLATE_NOTICE_ITEM);

            if (data.allNotice.Count == 0)
            {
                itemTemplate.transform.parent.gameObject.SetActive(false);
                contentTemplate.transform.parent.gameObject.SetActive(false);
                return;
            }

            itemTemplate.transform.parent.gameObject.SetActive(true);
            contentTemplate.transform.parent.gameObject.SetActive(true);

            for (int i = 0; i < data.allNotice.Count; i++)
            {
                var notice = data.allNotice[i];

                var main = notice.GetMainTitle();

                var gameobj = this.GetTemplateInstance(TEMPLATE_NOTICE_ITEM, this.itemTemplate.transform.parent, true);

                gameobj.transform.Find("Text").GetComponent <Text>().text = main.title;

                gameobj.transform.Find("NewTag").gameObject.SetActive(notice.isNew);

                var tag1 = gameobj.transform.Find("Tag_1");
                var tag2 = gameobj.transform.Find("Tag_2");

                tag1.gameObject.SetActive(false);
                tag2.gameObject.SetActive(false);


                if (notice.type == 1)
                {
                    //公告
                    tag1.gameObject.SetActive(true);
                }
                else if (notice.type == 2)
                {
                    //活动
                    tag2.gameObject.SetActive(true);
                }

                notice.gameobj = gameobj;
                gameobj.GetComponent <Button>().onClick.RemoveAllListeners();

                var info = notice;

                var idx = i;

                gameobj.GetComponent <Button>().onClick.AddListener(() =>
                {
                    Debug.Log("click info" + idx);
                    this.curIndex = idx;
                    UpdateSelects();
                });
            }

            this.curIndex = 0;

            UpdateSelects();

            LayoutRebuilder.ForceRebuildLayoutImmediate(this.itemTemplate.GetComponent <RectTransform>());
        }