local UIGuildWarBattleGround = UIViewClass() function UIGuildWarBattleGround:OnOpened(context) if context then self.toggles_Tab:SelectIndex(context.selectIndex) else self.toggles_Tab:SelectIndex(0) end end function UIGuildWarBattleGround:OnBackButtonPressed() self:OnButtonClicked(self.btn_Close) end function UIGuildWarBattleGround:OnButtonClicked(comp) if comp == self.group_Info[1].img_Chk01 then self:ShowMainInfo(1) self.group_Info[1].selectState:SetState(0) elseif comp == self.group_Info[1].img_Chk02 then self:ShowMainInfo(3) self.group_Info[1].selectState:SetState(1) elseif comp == self.group_Info[1].img_Chk03 then self:ShowMainInfo(2) self.group_Info[1].selectState:SetState(1) elseif comp == self.group_Info[1].img_Chk04 then self:ShowMainInfo(3) self.group_Info[1].selectState:SetState(2) elseif comp == self.btn_Close then self:CloseView() elseif comp == self.btn_Before then self:ShowBefore() elseif comp == self.btn_Next then self:ShowNext() else self:ClickItem(comp) end end function UIGuildWarBattleGround:ShowNext() self.curSelectIndex = self.curSelectIndex + 1 self.toggles_Tab:SelectIndex(self.curSelectIndex) end function UIGuildWarBattleGround:ShowBefore() self.curSelectIndex = self.curSelectIndex - 1 self.toggles_Tab:SelectIndex(self.curSelectIndex) end function UIGuildWarBattleGround:ClickItem(comp) for i = 2, 5 do for k,v in ipairs(self.group_Info[i]) do if v.btn_Icon == comp then local data = DataSheetManager.GuildWarBattleIntroDetails:GetDataByID_ElementID(i,k) if data then UIUtils.SetLabelText(self.txt_Name, Const_IDS[data.Name]) UIUtils.SetLabelText(self.txt_Info, Const_IDS[data.Intro]) UIUtils.SetLabelText(self.txt_Target, Const_IDS[data.Tag]) self.txt_Info.text = self:GetDesc(data) self.group_Icon:SetState(data.IconID-1) self.group_Icon.gameObject:SetActive(true) end for index,v in ipairs(self.group_Info[i]) do self.group_Info[i][index].img_Chk.gameObject:SetActive(index==k) end end end end end function UIGuildWarBattleGround:ShowMainInfo(id) local data = DataSheetManager.GuildWarBattleIntroSummary:GetDataByID(id) UIUtils.SetLabelText(self.txt_Name, Const_IDS[data.Name]) UIUtils.SetLabelText(self.txt_Info, Const_IDS[data.Intro]) UIUtils.SetLabelText(self.txt_Target, Const_IDS[data.Tag]) self.group_Icon.gameObject:SetActive(false) local state = self:GetMapState() if state then self.group_Info[1].mapState.gameObject:SetActive(true) self.group_Info[1].mapState:SetState(state) else self.group_Info[1].mapState.gameObject:SetActive(false) end end function UIGuildWarBattleGround:GetDesc(data) if #data.Variable_Table > 0 then local params = {} for i,v in ipairs(data.Variable_Table) do local excel = DataSheetManager[v.TableName] local key = tonumber(v.KeyId) or v.KeyId table.insert(params, excel["GetDataBy"..v.KeyName](excel, key)[v.ColumnName]) end return string.FormatByIdsKey(data.Intro, unpack(params)) else return UIUtils.GetLocalizedTxt(Const_IDS[data.Intro]) end end function UIGuildWarBattleGround:OnValueChanged(comp, value) if comp == self.toggles_Tab then self.curSelectIndex = value if value == 0 then self:ShowMainMap() else self:ShowDetail(value) end self.btn_Before.gameObject:SetActive(self.curSelectIndex ~= 0) self.btn_Next.gameObject:SetActive(self.curSelectIndex ~= 3) end end function UIGuildWarBattleGround:ShowMainMap() self.group_Info[1].gameObject:SetActive(true) for i=2,5 do self.group_Info[i].gameObject:SetActive(false) end self:ShowDefaultMap() end function UIGuildWarBattleGround:ShowDetail(value) for i=1,5 do self.group_Info[i].gameObject:SetActive(i == value + 1) end local data = DataSheetManager.GuildWarBattleIntroDetails:GetDataByID_ElementID(value+1,1) UIUtils.SetLabelText(self.txt_Name, Const_IDS[data.Name]) UIUtils.SetLabelText(self.txt_Info, Const_IDS[data.Intro]) UIUtils.SetLabelText(self.txt_Target, Const_IDS[data.Tag]) self.txt_Info.text = self:GetDesc(data) self.group_Icon:SetState(data.IconID-1) self.group_Icon.gameObject:SetActive(true) for index,v in ipairs(self.group_Info[value + 1]) do self.group_Info[value + 1][index].img_Chk.gameObject:SetActive(index==1) end for key, data in DataSheetManager.GuildWarBattleIntroDetails:GetDataByID_ElementID(value+1) do UIUtils.SetLabelText(self.group_Info[value+1][data.ElementID].lab_Name,Const_IDS[data.Name]) end end function UIGuildWarBattleGround:GetMapState() local groupInfos = MDL.GuildWar.GetGroupInfos() if groupInfos then local index = -1 for i,v in ipairs(groupInfos) do for k,player in ipairs(v.players) do if player.isHasPlayer and player.headInfo.acid == BattleDataGetter.GetAcID() then index = i end end end if index>0 then if index == 1 then return 3 -- 中央战场 elseif index == 2 then return 0 --码头战场 else return 1 --资源战场 end end end return 3 end function UIGuildWarBattleGround:ShowDefaultMap() local state = self:GetMapState() if state then if state == 1 then self:ShowMainInfo(3) self.group_Info[1].selectState:SetState(2) elseif state == 2 then self:ShowMainInfo(4) self.group_Info[1].selectState:SetState(3) elseif state == 3 then self:ShowMainInfo(2) self.group_Info[1].selectState:SetState(1) else self:ShowMainInfo(1) self.group_Info[1].selectState:SetState(0) end else self:ShowMainInfo(1) self.group_Info[1].selectState:SetState(0) end end return UIGuildWarBattleGround