Example #1
0
        public void SetMessageData(List <MessageItemData> listData)
        {
            if (listData == null)
            {
                return;
            }

            LTUIUtil.SetNumTemplate(templatedynamic, listItem, listData.Count, 0);

            for (int i = 0; i < listMessageItem.Count; i++)
            {
                if (i > listData.Count - 1)
                {
                    listMessageItem[i].mDMono.gameObject.CustomSetActive(false);
                    continue;
                }
                listMessageItem[i].mDMono.gameObject.CustomSetActive(true);
                listMessageItem[i].titleDayLabel.text = string.Format("{0}.{1}.{2}", listData[i].year, listData[i].month, listData[i].day);
                for (int j = 0; j < listData[i].listCell.Count; j++)
                {
                    MessageCellData cell = listData[i].listCell[j];

                    if (j == 0)
                    {
                        listMessageItem[i].contentLabel.text = cell.content == null ? "" : cell.content;
                    }
                    else
                    {
                        if (cell.content == null)
                        {
                            listMessageItem[i].contentLabel.text += "";
                        }
                        else
                        {
                            listMessageItem[i].contentLabel.text += "\n" + cell.content;
                        }
                    }
                }

                if (i > 0)
                {
                    listMessageItem[i].mDMono.transform.localPosition = listMessageItem[i - 1].mDMono.transform.localPosition
                                                                        - new Vector3(0f, listMessageItem[i - 1].GetHeight(), 0f);
                }
            }
        }
Example #2
0
        public void SetLegionMessages(List <AllianceMessage> messages)
        {
            if (messages == null)
            {
                return;
            }

            legionData.listMessageItem.Clear();

            for (int i = 0; i < messages.Count; i++)
            {
                if (messages[i].Time > legionData.messageLastTime)
                {
                    legionData.messageLastTime        = messages[i].Time; //须记下最后一次的时间用来进行增量下载
                    legionData.messageLastRuntimeTime = Time.unscaledTime;
                }
                System.DateTime startTime = TimeZone.CurrentTimeZone.ToLocalTime(new System.DateTime(1970, 1, 1)); // 当地时区
                DateTime        dt        = startTime.AddSeconds(messages[i].Time);
                int             year      = dt.Year;
                int             month     = dt.Month;
                int             day       = dt.Day;
                int             hour      = dt.Hour;
                int             min       = dt.Minute;

                MessageCellData cellData = new MessageCellData(); //先构建必须构建的单元
                cellData.hour = hour;
                cellData.min  = dt.Minute;

                string hourStr = hour < 10 ? "0" + hour : hour.ToString();
                string minStr  = min < 10 ? "0" + min : min.ToString();
                switch (messages[i].Type)
                {
                case "create":
                    cellData.content = string.Format(LegionConfig.GetLegionText("ID_LEGION_SYSTEM_MESSAGE1"), hourStr, minStr, messages[i].Name);
                    break;

                case "join":
                    cellData.content = string.Format(LegionConfig.GetLegionText("ID_LEGION_SYSTEM_MESSAGE2"), hourStr, minStr, messages[i].Name);
                    break;

                case "leave":
                    cellData.content = string.Format(LegionConfig.GetLegionText("ID_LEGION_SYSTEM_MESSAGE3"), hourStr, minStr, messages[i].Name);
                    break;

                case "kick":
                    cellData.content = string.Format(LegionConfig.GetLegionText("ID_LEGION_SYSTEM_MESSAGE4"), hourStr, minStr, messages[i].Name);
                    break;

                case "promote":
                    cellData.content = string.Format(LegionConfig.GetLegionText("ID_LEGION_SYSTEM_MESSAGE5"), hourStr, minStr, messages[i].Name);
                    break;

                case "demote":
                    cellData.content = string.Format(LegionConfig.GetLegionText("ID_LEGION_SYSTEM_MESSAGE6"), hourStr, minStr, messages[i].Name);
                    break;

                case "newOwner":
                    cellData.content = string.Format(LegionConfig.GetLegionText("ID_LEGION_SYSTEM_MESSAGE7"), hourStr, minStr, messages[i].Name);
                    break;

                case "levelup":
                    cellData.content = string.Format(LegionConfig.GetLegionText("ID_LEGION_SYSTEM_MESSAGE8"), hourStr, minStr, messages[i].Name);
                    break;

                default:
                    break;
                }
                bool isFind = false;
                for (int j = 0; j < legionData.listMessageItem.Count; j++)
                {
                    if (legionData.listMessageItem[j].IsContain(year, month, day))
                    {
                        isFind = true;
                        legionData.listMessageItem[j].listCell.Add(cellData);
                        break;
                    }
                }

                if (!isFind)
                {
                    MessageItemData mid = new MessageItemData(); //找不到就创建大节点 并将单元加入
                    mid.year  = year;
                    mid.day   = day;
                    mid.month = month;
                    mid.listCell.Add(cellData);
                    legionData.listMessageItem.Insert(0, mid);
                }
            }

            if (LegionEvent.NotifyUpdateLegionMessages != null)
            {
                LegionEvent.NotifyUpdateLegionMessages(legionData.listMessageItem);
            }
        }