local UIGuildWarReadyView = UIViewClass() local Stages = MDL.GuildWar.Stages local Tags = MDL.GuildWar.Tags local FightStages = MDL.GuildWar.FightStages local MAXPAGECOUNT = 5 function UIGuildWarReadyView:OnOpened(context) self.maxPageCount = MAXPAGECOUNT self.info = MDL.GuildWar.GetWarInfo() if context.Stage == Stages.StageTypePrepare or ( context.Stage == Stages.StageTypeBattle and ( context.fightStage == FightStages.FirstFighting or context.fightStage == FightStages.FirstPrepare) ) then self.group_First.gameObject:SetActive(true) self.group_Second.gameObject:SetActive(false) self.isFirst = true self.isSecond = false UIUtils.SetLabelText(self.localLab_First, Const_IDS.IDS_GuildWar_Battle1) self.toggle_Bottom:SelectIndex(self:GetTagId() or 0) else self.pageCount = 1 self.isSecond = true self.group_First.gameObject:SetActive(false) self.group_Second.gameObject:SetActive(true) UIUtils.SetLabelText(self.localLab_First, Const_IDS.IDS_GuildWar_Battle2) self.toggle_Bottom:SelectIndex(self:GetTagId() or 0) end end function UIGuildWarReadyView:GetTagId() local myGuildId = MDL.Guild.GetMyGuildInfo().guildId if self.info.groupMatchInfo then --这里不知道为啥为空了 判一下吧 for i,v in ipairs(self.info.groupMatchInfo) do for _,info in ipairs(v.matchInfoFirst) do if info.guildRed.guildId == myGuildId or info.guildBlue.guildId == myGuildId then return v.tagId - 1 end end end end end function UIGuildWarReadyView:ShowPage() if self.pageCount == self.maxPageCount then self.btn_Next.gameObject:SetActive(false) else self.btn_Next.gameObject:SetActive(true) end if self.pageCount == 1 then self.btn_Before.gameObject:SetActive(false) else self.btn_Before.gameObject:SetActive(true) end local page = self.pageCount local isExist = false if not self.info.groupMatchInfo then logging.error(LTAG.ERROR, "重要日志 军团战对战数据为空 ", self.info) return end for i,v in pairs(self.info.groupMatchInfo) do if v.tagId == page or (page == MAXPAGECOUNT and v.tagId == 0) then self:SetFirstBattleInfo(v) isExist = true end end if not isExist then self:SetFirstBattleInfo({tagId = page, matchInfoSecond = {}, matchInfoFirst = {}}) end end function UIGuildWarReadyView:SetFirstBattleInfo(data) local id = data.tagId if data.tagId == 0 then id = 5 end if id ~= 5 then if self.isSecond then self.group_First.gameObject:SetActive(false) self.group_Second.gameObject:SetActive(true) self.group_Low.gameObject:SetActive(false) self:SetGuildInfo(self.group_Second[1],data.matchInfoSecond, 1, true,data) self:SetGuildInfo(self.group_Second[2],data.matchInfoSecond, 1, false,data) self:SetGuildInfo(self.group_Second[3],data.matchInfoSecond, 2, true,data) self:SetGuildInfo(self.group_Second[4],data.matchInfoSecond, 2, false,data) if id == 1 then self.txt_Intro.text = nil self.group_Second[1].img_State:SetState(0) self.group_Second[2].img_State:SetState(0) else UIUtils.SetLabelText(self.txt_Intro,Const_IDS.IDS_GuildWar_BattleIntro2) self.group_Second[1].img_State:SetState(1) self.group_Second[2].img_State:SetState(1) end else self.group_First.gameObject:SetActive(true) self.group_Second.gameObject:SetActive(false) self.group_Low.gameObject:SetActive(false) self:SetGuildInfo(self.group_First[1],data.matchInfoFirst, 1, true) self:SetGuildInfo(self.group_First[3],data.matchInfoFirst, 1, false) self:SetGuildInfo(self.group_First[2],data.matchInfoFirst, 2, true) self:SetGuildInfo(self.group_First[4],data.matchInfoFirst, 2, false) UIUtils.SetLabelText(self.txt_Intro,Const_IDS.IDS_GuildWar_BattleIntro1) end self.Title.gameObject:SetActive(true) if id == 1 then self.group_Second[5]:SetState(0) else self.group_Second[5]:SetState(1) end else self.LoopScroll_SignedGuild:ClearCells() self.group_First.gameObject:SetActive(false) self.group_Second.gameObject:SetActive(false) self.group_Low.gameObject:SetActive(true) local list = self:GetFreedomList(data) if list then for i,v in ipairs(list) do self.LoopScroll_SignedGuild:AddData({v[1], v[2]} ,0) end else for i,v in ipairs(data.matchInfoFirst) do self.LoopScroll_SignedGuild:AddData({v, data.matchInfoSecond[i]} ,0) end end self.Title.gameObject:SetActive(false) UIUtils.SetLabelText(self.txt_Intro,Const_IDS.IDS_GuildWar_RandomizedRival) end local excelData = DataSheetManager.GuildWarGroup:GetDataByID(id) UTL.Item.SetAtlasSprite(self.ico_Level, "UI_GuildWar", excelData.GroupImage) --self.localLab_SignedGuild.text = UTL.Color.FormatTextByColor(excelData.Color,UIUtils.GetLocalizedTxt(Const_IDS[excelData.GroupName])) self.lab_Switch:SetState(id-1) UIUtils.SetLabelText(self.localLab_SignedGuild,Const_IDS[excelData.GroupName]) end function UIGuildWarReadyView:GetFreedomList(data) ---这里需要优化 从list里找出自己的两场 然后排序 感觉可以优化 local list = {} local myGuildId = MDL.Guild.GetMyGuildInfo().guildId local tmpMatchInfo = {} for i,v in ipairs(data.matchInfoFirst) do local firstIsSelf = v.guildRed.guildId == myGuildId or v.guildBlue.guildId == myGuildId local second = data.matchInfoSecond[i] local secondIsSelf = second and (second.guildRed.guildId == myGuildId or second.guildBlue.guildId == myGuildId) if firstIsSelf and not secondIsSelf then list[1] = list[1] or {} list[1][1]= v tmpMatchInfo.matchInfoSecond = data.matchInfoSecond[i] end if secondIsSelf and not firstIsSelf then list[1] = list[1] or {} list[1][2] = second tmpMatchInfo.matchInfoFirst = v end if secondIsSelf and firstIsSelf then list[1] = list[1] or {} list[1][1]= v list[1][2] = second end end if next(list) then if next(tmpMatchInfo) then table.insert( list,{tmpMatchInfo.matchInfoFirst,tmpMatchInfo.matchInfoSecond}) end for i,v in ipairs(data.matchInfoFirst) do local isSelf = v.guildRed.guildId == myGuildId or v.guildBlue.guildId == myGuildId local second = data.matchInfoSecond[i] if isSelf or (second and (second.guildRed.guildId == myGuildId or second.guildBlue.guildId == myGuildId)) then isSelf = true end if not isSelf then table.insert( list, {data.matchInfoFirst[i], data.matchInfoSecond[i]} ) end end return list else return nil end end function UIGuildWarReadyView:SetGuildInfo(obj, list, index, isRed,info) if list[index] then local data = nil local isWin = false if isRed then data = list[index].guildRed isWin =list[index].Result == 1 else data = list[index].guildBlue isWin = list[index].Result == 2 end if data and IsServerDataNotNil(data) then -- 跨服信息 if CTL.GuildWar.IsShowCrossServerUI() then local serverId = data.zoneInfo.serverId UIUtils.SetActive(obj.txt_CrossServer, true) UIUtils.SetLabel(obj.txt_CrossServer, string.FormatByIdsId(Const_IDS["IDS_CrossSever_SeverInfoText"], CTL.CrossServer.GetServerIDAndServerNameByServerID(serverId))) else UIUtils.SetActive(obj.txt_CrossServer, false) end obj.localLab_GuildName.text = data.guildName obj.txt_TitleGuildName.text = data.emblemContent obj.Group_MyGuild.gameObject:SetActive(data.guildId == MDL.Guild.GetMyGuildInfo().guildId ) obj.ico_GuildBg.gameObject:SetActive(true) UTL.Item.SetAtlasSprite(obj.ico_GuildBg, "UI_Guild", DataSheetManager.GuildEmblem:GetDataByID(data.emblemFrame).Image) self:SetBattleRes(obj,data,info and info.doubleWin, info and info.doubleDefeat) self:SetBattleBgRes(obj,isWin) return end end UIUtils.SetActive(obj.txt_CrossServer, false) obj.txt_TitleGuildName.text = nil obj.Group_MyGuild.gameObject:SetActive(false) UIUtils.SetLabelText(obj.localLab_GuildName, Const_IDS.IDS_GuildWar_NoRival) obj.ico_GuildBg.gameObject:SetActive(false) self:SetBattleRes(obj) self:SetBattleBgRes(obj,false) end function UIGuildWarReadyView:SetBattleRes(obj,data,doubleWin,doubleDefeat) local info = MDL.GuildWar.GetWarInfo() local isSecondEnd = false if data and info.Stage == Stages.StageTypeEnd or info.fightStage == FightStages.SecondEnd then isSecondEnd = true end if isSecondEnd then if data then if obj.ico_Cup then obj.ico_Cup.gameObject:SetActive(data.guildId == doubleWin) end if obj.group_ReduceLevel then obj.group_ReduceLevel.gameObject:SetActive(data.guildId == doubleDefeat) end return end end if obj.ico_Cup then obj.ico_Cup.gameObject:SetActive(false) end if obj.group_ReduceLevel then obj.group_ReduceLevel.gameObject:SetActive(false) end end function UIGuildWarReadyView:SetBattleBgRes(obj,isWind) if obj.bg1 then if isWind then obj.bg1.gameObject:SetActive(false) obj.bg2.gameObject:SetActive(true) else obj.bg1.gameObject:SetActive(true) obj.bg2.gameObject:SetActive(false) end end end function UIGuildWarReadyView:ShowBeforePage() self.pageCount = self.pageCount - 1 self.toggle_Bottom:SelectIndex(self.pageCount - 1) end function UIGuildWarReadyView:ShowNextPage() self.pageCount = self.pageCount + 1 self.toggle_Bottom:SelectIndex(self.pageCount - 1) end function UIGuildWarReadyView:OnButtonClicked(comp) if comp == self.btn_Before then self:ShowBeforePage() elseif comp == self.btn_Next then self:ShowNextPage() end end function UIGuildWarReadyView:OnCellInit(scrollRect, index, cellTable, data) if scrollRect == self.LoopScroll_SignedGuild then self:SetFreedomGroup(cellTable.group_Guild_L1, data[1].guildRed, data[1].Result==1) self:SetFreedomGroup(cellTable.group_Guild_R1, data[1].guildBlue, data[1].Result==2) self:SetFreedomGroup(cellTable.group_Guild_L2, data[2].guildRed, data[2].Result==1) self:SetFreedomGroup(cellTable.group_Guild_R2, data[2].guildBlue, data[2].Result==2) end end function UIGuildWarReadyView:SetFreedomGroup(obj,data,isWind) if data and IsServerDataNotNil(data) then obj.localLab_GuildName.text = data.guildName obj.txt_TitleGuildName.text = data.emblemContent if CTL.GuildWar.IsShowCrossServerUI() then UIUtils.SetLabel(obj.localLab_GuildName, data.guildName..string.FormatByIdsId(Const_IDS["IDS_CrossSever_SeverSuffixText1"], data.zoneInfo.serverId)) end obj.Group_MyGuild.gameObject:SetActive(data.guildId == MDL.Guild.GetMyGuildInfo().guildId ) obj.ico_GuildBg.gameObject:SetActive(true) if DataSheetManager.GuildEmblem:GetDataByID(data.emblemFrame) then UTL.Item.SetAtlasSprite(obj.ico_GuildBg, "UI_Guild", DataSheetManager.GuildEmblem:GetDataByID(data.emblemFrame).Image) end obj.bg1.gameObject:SetActive(not isWind) obj.bg2.gameObject:SetActive(isWind) else UIUtils.SetActive(obj.txt_CrossServer, false) obj.txt_TitleGuildName.text = nil obj.Group_MyGuild.gameObject:SetActive(false) UIUtils.SetLabelText(obj.localLab_GuildName, Const_IDS.IDS_GuildWar_NoRival) obj.ico_GuildBg.gameObject:SetActive(false) end end function UIGuildWarReadyView:OnValueChanged(comp, value) if comp == self.toggle_Bottom then self.pageCount = value + 1 self:ShowPage(value + 1) end end return UIGuildWarReadyView