--- 国战晚间boss奖励预览界面 --- local UICountryNightBossReward = UIViewClass() local RANK_INDEX_FORMAT_STR = "%s-%s" local RewardType = { Country = 1, Personal = 2, Special = 3, } function UICountryNightBossReward:OnCreated() self.leftTabData = { [1] = { mainID = 0, text = Const_IDS["IDS_CountryNightBoss_ContributionToEachBoss"], type = RewardType.Country, isParent = true, }, [2] = { mainID = 1, text = Const_IDS["IDS_CountryNightBoss_PersonalReward"], isParent = true, Children = { [1] = { subIndex = 1, text = Const_IDS["IDS_CountryNightBoss_PersonalRankReward"], type = RewardType.Personal, parentIndex = 1, }, [2] = { subIndex = 2, text = Const_IDS["IDS_CountryNightBoss_PersonalSpecialReward"], type = RewardType.Special, parentIndex = 1 } } }, } end function UICountryNightBossReward:OnOpened(context) UIUtils.SetLabelText(self.UICommonPopUpTab.txt_Title, Const_IDS["IDS_CountryNightBoss_PreviewReward"]) UIUtils.SetLabel(self.lab_Notice, string.FormatByIdsId(Const_IDS["IDS_CountryNightBoss_CountryRankRewardTips1"], MDL.CountryNightBoss.DamageCountryLimitFactor)) self.leftLoop = self.UICommonPopUpTab.loop_Tab self.selectMainID = 0 self.selectTabIndex = -1 self:LoadTabs() self.leftLoop:SelectIndex(self.selectMainID) end function UICountryNightBossReward:LoadTabs() if self.leftLoop.Count > 0 then self.leftLoop:ClearCells() end for _, mainTabData in ipairs(self.leftTabData) do self.leftLoop:AddData(mainTabData, 0) if mainTabData.Children and #mainTabData.Children > 0 and self.selectMainID == mainTabData.mainID then for _, childData in ipairs(mainTabData.Children) do self.leftLoop:AddData(childData, 1) end end end end function UICountryNightBossReward:OnButtonClicked(comp) if comp == self.UICommonPopUpTab.btn_Close then self:CloseView() elseif comp == self.btn_Info1 then -- 首领排行奖励 活动积分提示 self:SetReminder(comp, Const_IDS["IDS_CountryNightBoss_CountryRankRewardTips2"]) elseif comp == self.btn_Info2 then -- 首领排行奖励 国民奖励提示 self:SetReminder(comp, Const_IDS["IDS_CountryNightBoss_CountryRankRewardTips3"]) elseif comp == self.btn_Close then UIUtils.SetActive(self.group_InfoNotice.gameObject, false) end end function UICountryNightBossReward:RefreshRewards(rewardType) UIUtils.SetActive(self.group_Notice.gameObject, false) if rewardType == RewardType.Country then self:LoadCountryRewards() elseif rewardType == RewardType.Personal then self:LoadPersonalRewards() elseif rewardType == RewardType.Special then self:LoadSpecialRewards() end end -- 排行奖励显示数据Array local rankArray = {} function UICountryNightBossReward:LoadCountryRewards() self.state_Info:SetState(0) UIUtils.SetActive(self.group_Notice.gameObject, true) table.clearArray(rankArray) for _, rewardData in DataSheetManager.CountryNightBossRankRewardC:GetEnumerator() do table.insert(rankArray, rewardData) end self.loop_CountryRank:ReloadAll(rankArray) end function UICountryNightBossReward:LoadPersonalRewards() self.state_Info:SetState(1) table.clearArray(rankArray) for _, rewardData in DataSheetManager.CountryNightBossRankRewardP:GetEnumerator() do table.insert(rankArray, rewardData) end self.loop_PlayerRank:ReloadAll(rankArray) end function UICountryNightBossReward:LoadSpecialRewards() self.state_Info:SetState(2) table.clearArray(rankArray) for _, rewardData in DataSheetManager.CountryNightBossSpecialReward:GetEnumerator() do table.insert(rankArray, rewardData) end self.loop_ContributionReward:ReloadAll(rankArray) end function UICountryNightBossReward:RefreshItemRewards(cellTb, rewardData) if #cellTb.ItemContent <= 0 then for i, rewardData in ipairs(rewardData.Item_Table) do local contentItem = self:InstantiateCellCollection(cellTb.cell.gameObject, cellTb.ItemContent, self.item_Template.gameObject) UIUtils.SetActive(contentItem.gameObject, true) contentItem.ItemID = rewardData.ItemID UTL.Item.SetItemCell(contentItem.item, rewardData.ItemID, rewardData.ItemNum, false) UIUtils.SetActive(contentItem.img_All.gameObject, rewardData.IfAllMember == true and true or false) end end end function UICountryNightBossReward:OnCellInit(scrollRect, index, cellTable, data) if scrollRect == self.leftLoop then if data.isParent then cellTable.state_ArrowState:SetState(data.Children ~= nil and 1 or 0) UIUtils.SetActive(cellTable.img_Selected, self.selectMainID == data.mainID) UIUtils.SetActive(cellTable.img_UnSelected, self.selectMainID ~= data.mainID) else UIUtils.SetActive(cellTable.img_Selected, index == self.selectTabIndex) UIUtils.SetActive(cellTable.img_UnSelected, index ~= self.selectTabIndex) end UIUtils.SetLabelText(cellTable.txt_Name_Nomal, data.text) UIUtils.SetLabelText(cellTable.txt_Name_Selected, data.text) else -- 创建奖励item self:RefreshItemRewards(cellTable, data) if scrollRect == self.loop_CountryRank then -- 国家排行奖励 cellTable.state_RankIcon:SetState(index) UIUtils.SetLabel(cellTable.txt_Integral, data.Score) elseif scrollRect == self.loop_PlayerRank then -- 排名奖励 if data.RankEnd > 0 then UIUtils.SetLabel(cellTable.txt_Rank, string.format(RANK_INDEX_FORMAT_STR, data.RankBegin, data.RankEnd)) else UIUtils.SetLabel(cellTable.txt_Rank, string.FormatByIdsId(Const_IDS["IDS_CountryNightBoss_More"], data.RankBegin)) end elseif scrollRect == self.loop_ContributionReward then -- 特殊奖励 UIUtils.SetLabelText(cellTable.txt_Rank, Const_IDS[data.RewardName]) end end end function UICountryNightBossReward:OnCellSelect(scrollRect, index, cellTable, data) if data.isParent then self.selectMainID = data.mainID -- 先清除其他父类页签的 self:LoadTabs() if data.Children ~= nil and #data.Children > 0 then self.leftLoop:SelectIndex(data.mainID + 1) return end else if self.selectTabIndex == index then return end end if data.type then -- 展示右侧奖励展示 self:RefreshRewards(data.type) end end function UICountryNightBossReward:OnCellClicked(scrollRect, index, cellTable, target, data) local isRankShowScroll = scrollRect == self.loop_ContributionReward or scrollRect == self.loop_PlayerRank or scrollRect == self.loop_CountryRank if isRankShowScroll then for index, itemData in ipairs(data.Item_Table) do if target == cellTable.ItemContent[index].item.event_Click then UTL.ItemTips.ShowCommonTipsById(itemData.ItemID) return end end end end function UICountryNightBossReward:SetReminder(comp, ids) UIUtils.SetActive(self.group_InfoNotice.gameObject, true) UIUtils.SetLabelText(self.txt_Info, ids) self.group_InfoNotice.transform:SetPosition(comp.transform.position.x - 0.5, comp.transform.position.y - 0.2, 0) end return UICountryNightBossReward