local UIGuildEscortTownPanel = UIViewClass() -- [[ -- 势力押镖-押镖列表 -- ]] local RefreshInterval = 0.5 -------------------- function UIGuildEscortTownPanel:OnCreated() self.radius = DataSheetManager.ConstData:GetDataByID("EscortlListDistance").IntValue end function UIGuildEscortTownPanel:OnOpened(context) self:RegistSystemEvent(EventID.GuildEscort_MyCartFollow, self.ShowFollow) self:RegistSystemEvent(EventID.GuildEscort_Town_HideSelf, self.HideSelf) self.cartList = {} if CTL.GuildEscort.IsTransport() then UIUtils.SetActive(self.btn_Follow, not BattleDataGetter.SelfIsFollowNPC()) end self:RefreshList() -- 开启计时器 self:StartRepeatFunc(self.RefreshList, RefreshInterval) end function UIGuildEscortTownPanel:OnButtonClicked(comp) if self.btn_Follow == comp then CTL.GuildEscort.BeginFollowCart() elseif self.btn_MoveTo == comp then CTL.GuildEscort.GotoGuildEscortScene(true) end end function UIGuildEscortTownPanel:OnCellInit(scrollRect, index, cellTable, data) if scrollRect == self.loop_EscortList then local info = data.info local cartInfo = info.cartInfo -- 设置镖车所有人信息 UIUtils.SetLabel(cellTable.txt_PlayerName, info.ownerName) if cartInfo.ownerInfo.serverShowId == 0 then UIUtils.SetLabelText(cellTable.txt_Server, Const_IDS.IDS_Escort_SameServer) else local serverStr = string.FormatByIdsId(Const_IDS.IDS_ServerInfo, cartInfo.ownerInfo.serverShowId) UIUtils.SetLabel(cellTable.txt_Server, string.FormatByIdsId(Const_IDS.IDS_BreakThrough_SkillName, serverStr)) end --设置国家标识 local countryId = cartInfo.ownerInfo.countryInfo.countryId CTL.GuildEscort.SetUICountryShow(cellTable.img_CountryBg, cellTable.state_Country, countryId, cellTable.txt_Country) -- 设置镖车品质 local escortData = DataSheetManager.GuildEscortData:GetDataByID(cartInfo.quality) if escortData then local colorStr = UTL.Color.FormatTextByColor(escortData.NameColor, UIUtils.GetLocalizedTxt(Const_IDS[escortData.NameDes])) UIUtils.SetImageByAssetBundle(cellTable.img_Mark, escortData.CarIcon) cellTable.obj_CartState:SetState(cartInfo.quality - 1) -- C# 从0开始 else logging.error(LTAG.ERROR, "没有找到品质为:", cartInfo.quality, " 的镖车数据,请检查配置表 或者 下发数据") end -- 设置军团徽记 local guildShow = cartInfo.ownerInfo.guildShow local emblemContent = guildShow.emblemContent if string.isNilOrEmpty(emblemContent) then UIUtils.SetActive(cellTable.img_Guild, false) else UIUtils.SetActive(cellTable.img_Guild, true) UIUtils.SetLabel(cellTable.txt_Guild, emblemContent) local guildEmblemCfg = DataSheetManager.GuildEmblem:GetDataByID(guildShow.emblemFrame) if guildEmblemCfg then UTL.Item.SetAtlasSprite(cellTable.img_Guild, "UI_Guild", guildEmblemCfg.Image) end end -- 设置是否为仇人或者被劫镖过 UIUtils.SetActive(cellTable.img_Foe, MDL.GuildEscort.IsShowPlayerRival(info.ownerAcid)) -- 设置被劫次数&是否在战斗中 if data.inBattle then -- 掠夺次数是在战斗结束后增加,所以此处提前增加 1 UIUtils.SetLabel(cellTable.txt_State, string.FormatByIdsId(Const_IDS.IDS_Escort_BeRobedTime, data.robCount + 1)) else if data.robCount > 0 then UIUtils.SetLabel(cellTable.txt_State, string.FormatByIdsId(Const_IDS.IDS_Escort_HaveRobedTime, data.robCount)) else UIUtils.SetLabel(cellTable.txt_State, "") end end end end function UIGuildEscortTownPanel:OnCellClicked(scrollRect, index, cellTable, target, data) if scrollRect == self.loop_EscortList then MDL.GuildEscort.EscortPreBattleRequest(data.info) end end -------------------- -- 劫镖时列表刷新 function UIGuildEscortTownPanel:RefreshList(deltaTime, timeSinceUpdate) if CTL.GuildEscort.IsTransport() then UIUtils.SetActive(self.group_BuffDetailInfo, false) UIUtils.SetActive(self.btn_MoveTo, false) return end UIUtils.SetActive(self.btn_Follow, false) table.clear(self.cartList) BattleDataGetter.GetCartsListAroundMe(self.radius, self.cartList) if #self.cartList > 0 then UIUtils.SetActive(self.group_BuffDetailInfo, true) local enabledLoop = #self.cartList ~= self.loop_EscortList.Count if enabledLoop then self.loop_EscortList.enabled = false end self.loop_EscortList:ReloadAll(self.cartList) if enabledLoop then self.loop_EscortList.enabled = true end UIUtils.SetActive(self.btn_MoveTo, false) else UIUtils.SetActive(self.group_BuffDetailInfo, false) self:ShowMoveTo() end end -- 运镖时跟随按钮显隐 function UIGuildEscortTownPanel:ShowFollow(show) if not CTL.GuildEscort.IsTransport() then UIUtils.SetActive(self.btn_Follow, false) return end UIUtils.SetActive(self.btn_Follow, not show) end -- 在场景中显示前往按钮 function UIGuildEscortTownPanel:ShowMoveTo() local residueEscortNum = MDL.GuildEscort.GetEscortNumLimit() local opening = CTL.Activities.IsOpeningTime(LuaConst.ActivityType.GuildEscort) UIUtils.SetActive(self.btn_MoveTo, opening and residueEscortNum > 0) end -- 某些情况需要隐藏该界面(如:打开主界面功能栏) function UIGuildEscortTownPanel:HideSelf(isShow) UIUtils.SetActive(self.gameObject, isShow) end return UIGuildEscortTownPanel