local UIGuildEscortListPanel = UIViewClass() -- [[ -- 势力押镖-押镖列表具体展示 -- ]] local RefreshInterval = 10 -------------------- function UIGuildEscortListPanel:OnCreated() self.radius = DataSheetManager.ConstData:GetDataByID("EscortlListDistance").IntValue end function UIGuildEscortListPanel:OnOpened(context) self:RegistSystemEvent(EventID.GuildEscort_RefreshActivityCount, self.RefreshEscortResidueInfo) self:RegistSystemEvent(EventID.GuildEscort_RefreshEscortListPanel, self.InitPanel) self:InitPanel(context) self:RefreshEscortResidueInfo() self:RefreshList() -- 开启计时器 self:StartRepeatFunc(self.RefreshList, RefreshInterval) end function UIGuildEscortListPanel:OnBackButtonPressed() self:OnButtonClicked(self.event_BgClose) end function UIGuildEscortListPanel:OnButtonClicked(comp) if comp == self.event_BgClose then self:CloseView() elseif comp == self.btn_Confirm then --判断是否同国家 local countryId = self.objectSceneBasic.cartInfo.ownerInfo.countryInfo.countryId if MDL.Country.IsSameCountry(countryId) then CTL.Tips.AddTipsMsg(Const_IDS.IDS_Escort_SameCountry) return end local guildId = self.objectSceneBasic.cartInfo.ownerInfo.guildShow.guildId if MDL.Guild.IsSameGuild(guildId) then CTL.Tips.AddTipsMsg(UIUtils.GetLocalizedTxt(Const_IDS.IDS_Escort_OutSameGuild)) else MDL.GuildEscort.EscortStartRequest(self.objectSceneBasic.uniqId) self:CloseView() end else for i, reward in ipairs(self.cutEscort.personalRewards) do if self.Content[i].event_Click == comp then UTL.ItemTips.ShowCommonTipsById(reward.ItemId) end end end end function UIGuildEscortListPanel:OnCellInit(scrollRect, index, cellTable, data) if scrollRect == self.channelScroll then local info = data.info UIUtils.SetLabel(cellTable.text_Name, info.ownerName) CTL.Character.SetPortraitAndFrame(cellTable.HeroHead, info.cartInfo.ownerInfo.portraitId, info.cartInfo.ownerInfo.frameId) -- 设置是否为仇人或者被劫镖过 UIUtils.SetActive(cellTable.img_Foe, MDL.GuildEscort.IsShowPlayerRival(info.ownerAcid)) --设置国家标识 local countryId = info.cartInfo.ownerInfo.countryInfo.countryId CTL.GuildEscort.SetUICountryShow(cellTable.img_CountryBg, cellTable.state_Country, countryId, cellTable.txt_Country) end end function UIGuildEscortListPanel:OnCellClicked(scrollRect, index, cellTable, target, data) if scrollRect == self.channelScroll then if target == cellTable.event_UnSelect then MDL.GuildEscort.EscortPreBattleRequest(data.info) end end end -------------------- function UIGuildEscortListPanel:InitPanel(context) self.objectSceneBasic = context.ObjectSceneBasic self.cutEscort = context.CutEscort -- 设置镖车品质 self.obj_EscortState:SetState(self.objectSceneBasic.cartInfo.quality - 1) --设置国家标识 local countryId = self.objectSceneBasic.cartInfo.ownerInfo.countryInfo.countryId CTL.GuildEscort.SetUICountryShow(self.img_CountryBg, self.state_Country, countryId) -- 设置势力名称 UIUtils.SetLabel(self.txt_GuildName, self.objectSceneBasic.cartInfo.ownerInfo.guildShow.guildName) -- 设置势力徽记 local emblemContent = self.objectSceneBasic.cartInfo.ownerInfo.guildShow.emblemContent if string.isNilOrEmpty(emblemContent) then UIUtils.SetActive(self.img_Guild, false) else UIUtils.SetActive(self.img_Guild, true) UIUtils.SetLabel(self.txt_Guild, emblemContent) local guildEmblemCfg = DataSheetManager.GuildEmblem:GetDataByID(self.objectSceneBasic.cartInfo.ownerInfo.guildShow.emblemFrame) if guildEmblemCfg then UTL.Item.SetAtlasSprite(self.img_Guild, "UI_Guild", guildEmblemCfg.Image) end end -- 设置劫镖奖励 if self.cutEscort.personalRewards ~= nil and #self.cutEscort.personalRewards > 0 then UIUtils.SetActive(self.Content.gameObject, true) for i, reward in ipairs(self.cutEscort.personalRewards) do local item = self.Content[i] if not item then item = self:InstantiateCollection(self.Content, self.itemTemplate_Reward.gameObject) end UTL.Item.SetItemCell(item, reward.ItemId, reward.ItemCount) UIUtils.SetActive(item.gameObject, true) end for i = #self.cutEscort.personalRewards + 1, #self.Content do UIUtils.SetActive(self.Content[i].gameObject, false) end else UIUtils.SetActive(self.Content.gameObject, false) end -- 设置运镖玩家 for i, v in ipairs(self.cutEscort.enemyHeadInfo) do local item = self.obj_playerList[i] UIUtils.SetActive(item.gameObject, true) UIUtils.SetLabel(item.text_Name, v.name) UIUtils.SetLabel(item.text_BR, string.FormatByIdsId(Const_IDS.IDS_Escort_FightPower, v.gsSum)) CTL.Character.SetPortraitAndFrame(item.HeroHead, v.PortraitId, v.FrameId) end for i = #self.cutEscort.enemyHeadInfo + 1, #self.obj_playerList do UIUtils.SetActive(self.obj_playerList[i].gameObject, false) end end -- 刷新(劫镖)次数 function UIGuildEscortListPanel:RefreshEscortResidueInfo() local residueNum, limitNum = MDL.GuildEscort.GetCutEscortNumLimit() if residueNum <= 0 then UIUtils.SetLabel(self.text_Times, string.FormatByIdsId(Const_IDS.IDS_Escort_ActivityNum3, UTL.Color.FormatRedColor(residueNum), limitNum)) else UIUtils.SetLabel(self.text_Times, string.FormatByIdsId(Const_IDS.IDS_Escort_ActivityNum3, UTL.Color.FormatGreenColor(residueNum), limitNum)) end end -- 刷新附近人列表 function UIGuildEscortListPanel:RefreshList(deltaTime, timeSinceUpdate) local cartList = {} BattleDataGetter.GetCartsListAroundMe(self.radius, cartList) --JWS2-29942 押镖国战化这里需要过滤掉同国家的 for i = #cartList, 1, -1 do local countryId = cartList[i].info.cartInfo.ownerInfo.countryInfo.countryId if MDL.Country.IsSameCountry(countryId) then table.remove(cartList, i) end end if #cartList > 0 then UIUtils.SetActive(self.channelScroll.gameObject, true) self.channelScroll:ReloadAll(cartList) else UIUtils.SetActive(self.channelScroll.gameObject, false) end end return UIGuildEscortListPanel