local UIGVGFightSeasonReward = UIViewClass() local TabType = { Rank = 1, Earnings = 2, Occupy = 3, } local CityTypeIds = { "IDS_GVGFight_CityType1", --大型城池 "IDS_GVGFight_CityType2", --中型城池 "IDS_GVGFight_CityType3", --小型城池 "IDS_GVGFight_CityType4", --大营 } local GVGFightCityHarvestRation = FP.tonumberV1(DataSheetManager.ConstData:GetDataByID("GVGFightCityHarvestRation").FloatValue) function UIGVGFightSeasonReward:OnCreated() self.curTab = TabType.Rank self.clickItemDict = {} end function UIGVGFightSeasonReward:OnOpened(context) self:RegistSystemEvent(EventID.GVGFight_RefreshSeasonId, self.RefreshSeasonId) self:RegistSystemEvent(EventID.UI_RefreshRankInfo, self.RefreshRankInfo) self:RegistSystemEvent(EventID.GVGFight_RefreshGVGFightState, self.RefreshRankInfo) self:RegistSystemEvent(EventID.GVGFight_RefreshCityState, self.RefreshTab) self.UICommonPopUpTab.loop_Tab:AddData(TabType.Rank, 0) self.UICommonPopUpTab.loop_Tab:AddData(TabType.Earnings, 0) self.UICommonPopUpTab.loop_Tab:AddData(TabType.Occupy, 0) UIUtils.SetActive(self.UICommonPopUpTab.img_Info, true) UIUtils.SetLabelText(self.UICommonPopUpTab.txt_Title, Const_IDS.IDS_GVGFight_Reward_Title) self.UICommonPopUpTab.loop_Tab:SelectIndex(0) end function UIGVGFightSeasonReward:OnClosed() UIUtils.SetActive(self.UICommonPopUpTab.img_Info, false) end function UIGVGFightSeasonReward:RefreshSeasonId() self.UICommonPopUpTab.loop_Tab:RefreshCells() if self.curTab == TabType.Occupy then self:ShowOccupyView() end end function UIGVGFightSeasonReward:RefreshRankInfo() if self.curTab == TabType.Rank then self:ShowRankView() end end function UIGVGFightSeasonReward:OnBackButtonPressed() self:OnButtonClicked(self.UICommonPopUpTab.btn_Close) end function UIGVGFightSeasonReward:OnButtonClicked(comp) if comp == self.UICommonPopUpTab.btn_Close then self:CloseView() elseif comp == self.UICommonPopUpTab.img_Info then UIManager.OpenView(Const_UI_Lua.UIEnum.UICommonNoteView, {id = LuaConst.NoteID.GVGFightReward}) end end function UIGVGFightSeasonReward:RefreshTab() if self.curTab == TabType.Rank then MDL.Rank.GetRankInfoReq(MDL.Rank.RankType.GVGFight, {isPreRank = false}, CTL.Rank.SortType.MyServer) self:ShowRankView() elseif self.curTab == TabType.Earnings then self:ShowEarningsView() elseif self.curTab == TabType.Occupy then self:ShowOccupyView() end end function UIGVGFightSeasonReward:ShowRankView() self.state_SeasonReward:SetState(0) self.loopScroll_GVGSeasonRankReward:ClearCells() for k,v in DataSheetManager.GVGFightRank:GetEnumerator() do self.loopScroll_GVGSeasonRankReward:AddData(v, 0) end end function UIGVGFightSeasonReward:ShowEarningsView() self.state_SeasonReward:SetState(1) self.loopScroll_GVGContinuousIncome:ClearCells() for k,v in DataSheetManager.GVGFightCity:GetEnumerator() do if MDL.GVGFight.IsEffectiveCity(v.CityID) then self.loopScroll_GVGContinuousIncome:AddData(v, 0) end end end function UIGVGFightSeasonReward:ShowOccupyView() self.state_SeasonReward:SetState(2) self.loopScroll_GVGOccupationReward:ClearCells() for k,v in DataSheetManager.GVGFightCity:GetEnumerator() do if MDL.GVGFight.IsEffectiveCity(v.CityID) then self.loopScroll_GVGOccupationReward:AddData(v, 0) end end end function UIGVGFightSeasonReward:OnCellSelect(scrollRect, index, cellTable, data) if scrollRect == self.UICommonPopUpTab.loop_Tab then self.curTab = index + 1 self:RefreshTab() end end function UIGVGFightSeasonReward:OnRankCellInit(scrollRect, index, cellTable, data) if data.RankStart == data.RankEnd then cellTable.txt_Rank.text = string.FormatByIdsId(Const_IDS.IDS_DemonGod_UI_37, data.RankStart) else cellTable.txt_Rank.text = string.FormatByIdsId(Const_IDS.IDS_DemonGod_UI_37, data.RankStart.."-".. data.RankEnd) end local rewards = DataSheetManager.GVGFightRewardRepeat:GetDataByID(data.RewardID) for i, item in ipairs(rewards.Item_Table) do local obj = cellTable.Content[i] if obj == nil then obj = self:InstantiateCellCollection(cellTable.cell.gameObject, cellTable.Content, self.itemTemplate.gameObject) UIUtils.SetActive(obj.gameObject, true) end UIUtils.SetActive(obj.gameObject, true) if GameAppInfo.IsVersionGreaterThan16000() then self:InitCellUITemplate(cellTable.cell.gameObject, obj.item, cellTable.Content) end self.clickItemDict[obj.item.event_Click] = item.ItemID UTL.Item.SetItemCell(obj.item, item.ItemID, item.ItemNum) end for i = #rewards.Item_Table + 1, #cellTable.Content do local obj = cellTable.Content[i] UIUtils.SetActive(obj.gameObject, false) end local myRank = MDL.Rank.GetMyRankInfo() if myRank.index and myRank.index > 0 and data.RankStart <= myRank.index and data.RankEnd >= myRank.index then UIUtils.SetActive(cellTable.img_Own, true) else UIUtils.SetActive(cellTable.img_Own, false) end end function UIGVGFightSeasonReward:OnEarningsCellInit(scrollRect, index, cellTable, data) local info = MDL.GVGFight.GetCityOuterInfo(data.CityID) cellTable.state_Bg:SetState(index % 2) local cityBasicHarvestNum = data.CityBasicHarvestNum if info and info.isHighYield then cellTable.txt_ResidentName.text = UTL.Color.FormatTextByColor(data.CityNameColor, UIUtils.GetLocalizedTxt(Const_IDS[data.CityName])) UIUtils.SetActive(cellTable.txt_HighYield, true) cellTable.txt_HighYield.text = UTL.Color.FormatTextByColor(data.CityNameColor, UIUtils.GetLocalizedTxt(Const_IDS.IDS_GVGFight_CityDoubleHarvest)) cityBasicHarvestNum = cityBasicHarvestNum * GVGFightCityHarvestRation else UIUtils.SetActive(cellTable.txt_HighYield, false) cellTable.txt_ResidentName.text = UTL.Color.FormatTextByColor(data.CityNameColor, UIUtils.GetLocalizedTxt(Const_IDS[data.CityName])) end UTL.Item.MoneyIcon(cellTable.img_ResidentRevenue, data.CityBasicHarvestItem) cellTable.txt_ResidentRevenue.text = string.FormatByIdsId(Const_IDS.IDS_GVGFight_Reward_Tips5, cityBasicHarvestNum, data.CityBasicHarvestPerTime) UIUtils.SetImageByAssetBundle(cellTable.img_ResidentType, data.CityTypeIcon) cellTable.txt_ResidentType.text = UTL.Color.FormatTextByColor(data.CityNameColor, UIUtils.GetLocalizedTxt(Const_IDS[CityTypeIds[data.CityType]])) end function UIGVGFightSeasonReward:OnOccupyCellInit(scrollRect, index, cellTable, data) local info = MDL.GVGFight.GetCityOuterInfo(data.CityID) cellTable.state_Bg:SetState(index % 2) if info and info.isHighYield then cellTable.txt_ResidentName.text = UTL.Color.FormatTextByColor(data.CityNameColor, UIUtils.GetLocalizedTxt(Const_IDS[data.CityName])) UIUtils.SetActive(cellTable.txt_HighYield, true) cellTable.txt_HighYield.text = UTL.Color.FormatTextByColor(data.CityNameColor, UIUtils.GetLocalizedTxt(Const_IDS.IDS_GVGFight_CityDoubleHarvest)) else UIUtils.SetActive(cellTable.txt_HighYield, false) cellTable.txt_ResidentName.text = UTL.Color.FormatTextByColor(data.CityNameColor, UIUtils.GetLocalizedTxt(Const_IDS[data.CityName])) end local seasonRewardData = DataSheetManager.GVGFightCitySeasonReward:GetDataBySeasonIDMin_CityID(CTL.GVGFight.GetSeasonMinID(), data.CityID) local cityBasicCaptureRewardID = 0 if seasonRewardData then cityBasicCaptureRewardID = seasonRewardData.CityBasicCaptureRewardID end if cityBasicCaptureRewardID > 0 then local rewards = DataSheetManager.GVGFightRewardRepeat:GetDataByID(cityBasicCaptureRewardID) if rewards then for i, item in ipairs(rewards.Item_Table) do local obj = cellTable.Content[i] if obj == nil then obj = self:InstantiateCellCollection(cellTable.cell.gameObject, cellTable.Content, self.itemTemplate.gameObject) UIUtils.SetActive(obj.gameObject, true) end UIUtils.SetActive(obj.gameObject, true) if GameAppInfo.IsVersionGreaterThan16000() then self:InitCellUITemplate(cellTable.cell.gameObject, obj.item, cellTable.Content) end self.clickItemDict[obj.item.event_Click] = item.ItemID UTL.Item.SetItemCell(obj.item, item.ItemID, item.ItemNum) end for i = #rewards.Item_Table + 1, #cellTable.Content do local obj = cellTable.Content[i] UIUtils.SetActive(obj.gameObject, false) end cellTable.txt_noReward.text = nil else UIUtils.SetLabelText(cellTable.txt_noReward, Const_IDS.IDS_GVGFight_Reward_Tips4) for i = 1, #cellTable.Content do local obj = cellTable.Content[i] UIUtils.SetActive(obj.gameObject, false) end end else UIUtils.SetLabelText(cellTable.txt_noReward, Const_IDS.IDS_GVGFight_Reward_Tips4) for i = 1, #cellTable.Content do local obj = cellTable.Content[i] UIUtils.SetActive(obj.gameObject, false) end end cellTable.txt_ResidentType.text = UTL.Color.FormatTextByColor(data.CityNameColor, UIUtils.GetLocalizedTxt( Const_IDS[CityTypeIds[data.CityType]])) UIUtils.SetImageByAssetBundle(cellTable.img_ResidentType, data.CityTypeIcon) end function UIGVGFightSeasonReward:OnCellInit(scrollRect, index, cellTable, data) if scrollRect == self.UICommonPopUpTab.loop_Tab then local titleStr = "" if data == TabType.Rank then titleStr = UIUtils.GetLocalizedTxt(Const_IDS.IDS_GVGFight_Reward_Tab1) elseif data == TabType.Earnings then titleStr = UIUtils.GetLocalizedTxt(Const_IDS.IDS_GVGFight_Reward_Tab2) elseif data == TabType.Occupy then local currentSeasonId = MDL.GVGFight.GetCurSeasonId() if currentSeasonId == 0 then titleStr = UIUtils.GetLocalizedTxt(Const_IDS.IDS_GVGFight_Reward_Tab3_Special) else titleStr = string.FormatByIdsId(Const_IDS.IDS_GVGFight_Reward_Tab3, currentSeasonId) end end UIUtils.SetLabel(cellTable.txt_Name_Nomal, titleStr) UIUtils.SetLabel(cellTable.txt_Name_Selected, titleStr) UIUtils.SetActive(cellTable.img_Arrow, false) UIUtils.SetActive(cellTable.img_ArrowS, false) UIUtils.SetActive(cellTable.group_SignState, false) UIUtils.SetActive(cellTable.group_SignStateS, false) elseif scrollRect == self.loopScroll_GVGOccupationReward then self:OnOccupyCellInit(scrollRect, index, cellTable, data) elseif scrollRect == self.loopScroll_GVGContinuousIncome then self:OnEarningsCellInit(scrollRect, index, cellTable, data) elseif scrollRect == self.loopScroll_GVGSeasonRankReward then self:OnRankCellInit(scrollRect, index, cellTable, data) end end function UIGVGFightSeasonReward:OnCellClicked(scrollRect, index, cellTable, target, data) if self.clickItemDict[target] then UTL.ItemTips.ShowCommonTipsById(self.clickItemDict[target]) end end return UIGVGFightSeasonReward