-- 实时社交信息动态界面(世界boss、仇人系统等) local UIDynamicMessages = UIViewClass() local EventSystem = require('Event/EventSystem') ---------- start 辅助相关 start ---------- local MessageDataType = { WorldBoss = 1, Rival = 2, } -- 恩怨簿排序(追杀 > 求援 按照记录时间顺序排序,时间越近越靠前) local function SortMessageList(messageTbA, messageTbB) if messageTbA.messageType == MessageDataType.Rival and messageTbB.messageType ~= MessageDataType.Rival then return true elseif messageTbB.messageType == MessageDataType.Rival and messageTbA.messageType ~= MessageDataType.Rival then return false else return messageTbA.info.closeTime > messageTbB.info.closeTime end end ---------- end 辅助相关 end ---------- -------------------- function UIDynamicMessages:OnCreated() self.messageList = {} self.minTime = 0 end function UIDynamicMessages:OnOpened(context) UIUtils.SetLabelText(self.UICommonPopUp.txt_Title, Const_IDS.IDS_WorldBoss_HelpTitle) self:RegistSystemEvent(EventID.RefreshWorldBossHelp, self.OnRefreshDynamicMessage) self:RegistSystemEvent(EventID.UI_Rival_RefreshRemindMessageList, self.OnRefreshDynamicMessage) self:OnRefreshDynamicMessage() self:CloseAllUIDynamicHint() end function UIDynamicMessages:OnUpdateFun(deltaTime, timeSinceUpdate) self:StopRepeatFunc(self.OnUpdateFun) self:OnRefreshDynamicMessage() end function UIDynamicMessages:OnBackButtonPressed() self:OnButtonClicked(self.UICommonPopUp.btn_Close) end function UIDynamicMessages:OnButtonClicked(comp) if comp == self.UICommonPopUp.btn_Close then MDL.WorldBoss.ClearAllSeekHelp() self:CloseView() end end function UIDynamicMessages:OnCellInit(scrollRect, index, cellTable, data) if scrollRect == self.loop_Messages then cellTable.obj_StateBg:SetState(index % 2) -- 设置玩家头像、名字、军团(此处公有信息 尽量保证字段名字相同) CTL.Character.SetPortraitAndFrame(cellTable.UIHeroHeadTempate, data.info.portraitId, data.info.frameId, nil, data.info.acid) UIUtils.SetLabel(cellTable.txt_PlayerName, data.info.playerName) UIUtils.SetLabel(cellTable.txt_GuildName, data.info.guildName) if data.messageType == MessageDataType.WorldBoss then cellTable.obj_StateSwitch:SetState(0) local worldBossData = DataSheetManager.WorldBoss:GetDataByID(data.info.bossCfgId) local funcName = "" if worldBossData.BossType == LuaConst.WorldBossType.WorldBoss then funcName = UIUtils.GetLocalizedTxt(Const_IDS.IDS_ActivityName_WorldBoss) elseif worldBossData.BossType == LuaConst.WorldBossType.WarZoneWorldBoss then funcName = UIUtils.GetLocalizedTxt(Const_IDS.IDS_ActivityName_WarZoneBoss) end local bossName = UIUtils.GetLocalizedTxt(Const_IDS[worldBossData.WordBossName]) local locationDesc = string.format("%s.%s(%s)", funcName, bossName, CTL.WorldBoss.GetBossLevelStr(worldBossData.ShowLevel)) UIUtils.SetLabel(cellTable.txt_Location, locationDesc) if data.info.helpType == MDL.WorldBoss.HelpType.Killed then -- 判断是否被boss击杀,如果是boss则需要本地化boss名字 UIUtils.SetLabel(cellTable.lab_HelpInfo, string.FormatByIdsId(Const_IDS.IDS_WorldBoss_AttackedBySomeone, data.info.killerIsBoss and bossName or data.info.killerName)) elseif data.info.helpType == MDL.WorldBoss.HelpType.Attacked then UIUtils.SetLabelText(cellTable.lab_HelpInfo, Const_IDS.IDS_WorldBoss_AttackedByOthers) else UIUtils.SetLabelText(cellTable.lab_HelpInfo, Const_IDS.IDS_WorldBoss_AskForHelp) end elseif data.messageType == MessageDataType.Rival then cellTable.obj_StateSwitch:SetState(1) UIUtils.SetLabel(cellTable.txt_Hostility, string.FormatByIdsId(Const_IDS.IDS_Rival_ValueOfHatred, data.info.hatred)) local locationDesc = CTL.Rival.GetLocationDescByBattleInfo(data.info) UIUtils.SetLabel(cellTable.txt_Location, locationDesc) end -- 取最小值计时 local offsetTime = data.info.closeTime - UTL.Time.GetServerTimestamp() if self.minTime == 0 or self.minTime > offsetTime then self.minTime = offsetTime end cellTable.txt_Ignore:ResetAndBeginCustomTimer(false, offsetTime, 0, UIUtils.GetLocalizedTxt(Const_IDS.IDS_WorldBoss_IgonreCD), 1) end end function UIDynamicMessages:OnCellClicked(scrollRect, index, cellTable, target, data) if scrollRect == self.loop_Messages then if target == cellTable.btn_Ignore then if data.messageType == MessageDataType.WorldBoss then MDL.WorldBoss.DeleteHelpList(data.info.acid) elseif data.messageType == MessageDataType.Rival then MDL.Rival.DeleteRivalTracking(data.info.acid) end elseif target == cellTable.btn_Go then if data.messageType == MessageDataType.WorldBoss then MDL.WorldBoss.SendGotoHelpMsg(data.info.bossCfgId, data.info.GRoomID, data.info.acid) elseif data.messageType == MessageDataType.Rival then MDL.WorldBoss.SendGotoRivalMsg(data.info.syncBattleSubID, data.info.syncBattleGRoomID, data.info.acid) end end end end -------------------- function UIDynamicMessages:OnRefreshDynamicMessage() self.minTime = 0 local msgCount = 1 -- 此处处理数据 -- -- 世界boss local seekHelpList = MDL.WorldBoss.GetSeekHelpList() for _, v in ipairs(seekHelpList) do self.messageList[msgCount] = { info = v, messageType = MessageDataType.WorldBoss } msgCount = msgCount + 1 end -- 死敌追踪 for _, v in MDL.Rival.GetRivalTrackingIterator() do self.messageList[msgCount] = { info = v, messageType = MessageDataType.Rival } msgCount = msgCount + 1 end -- 此处处理数据 -- for i = #self.messageList, msgCount, -1 do table.remove(self.messageList, i) end table.sort(self.messageList, SortMessageList) if #self.messageList == 0 then UIUtils.SetActive(self.img_Empty, true) UIUtils.SetActive(self.loop_Messages, false) else UIUtils.SetActive(self.img_Empty, false) UIUtils.SetActive(self.loop_Messages, true) self.loop_Messages:ReloadAll(self.messageList) if self.minTime > 0 then self:StopRepeatFunc(self.OnUpdateFun) self:StartRepeatFunc(self.OnUpdateFun, self.minTime) end end end -- 详情界面打开时 关闭所有小hint界面 function UIDynamicMessages:CloseAllUIDynamicHint() EventSystem.Dispatch(EventID.UI_Rival_CloseRemind) EventSystem.Dispatch(EventID.UI_WorldBoss_CloseHelpRemind) end return UIDynamicMessages