local UIGuildBossReward = UIViewClass() local TabType = { guild = 1, personal = 2, lucky =3 } local TabInfo = { [1] = {index = 0, desc = "IDS_Auction_LootDesc"}, -- 势力 [2] = {index = 1, desc = "IDS_GuildBoss_RewardDesc1",popTip = "IDS_GuildBoss_RewardDesc2"}, -- 个人 [3] = {index = 2, desc = "IDS_GuildBoss_RewardDesc3", popTip = "IDS_GuildBoss_RewardDesc4"}, -- 幸运夺宝 } function UIGuildBossReward:OnOpened(context) self:RegistSystemEvent(EventID.WarZone_TimeRewardFresh, self.RefreshPage) self:RefreshPage() self.section_TypeTab:SelectIndex(0) end function UIGuildBossReward:RefreshPage() self.isCross = CTL.WarZone.IsWarZoneOpen() self.selectIndex = TabInfo[TabType.guild].index self.section_TypeTab:SelectIndex(self.selectIndex) end function UIGuildBossReward:OnValueChanged(comp, index) if comp == self.section_TypeTab then self.selectIndex = index if index == TabInfo[TabType.guild].index or index == TabInfo[TabType.personal].index then self.content_State:SetState(0) self:ShowRewards() elseif index == TabInfo[TabType.lucky].index then self.content_State:SetState(1) self:ShowLuckyReward() end end self:UpdateTipDesc() end function UIGuildBossReward:UpdateTipDesc() for _, v in ipairs(TabInfo) do if v.index == self.selectIndex then UIUtils.SetActive(self.btn_Info, v.popTip ~= nil) UIUtils.SetLabelText(self.txt_Tips, Const_IDS[v.desc]) end end end function UIGuildBossReward:ShowRewards() self.LoopScroll_GuildBossReward:ClearCells() if self.isCross then for _, v in DataSheetManager.GuildBossGuildRewardCrossSever:GetEnumerator() do self.LoopScroll_GuildBossReward:AddData(v, 0) end else for _, v in DataSheetManager.GuildBossGuildReward:GetEnumerator() do self.LoopScroll_GuildBossReward:AddData(v, 0) end end end -- 幸运夺宝 function UIGuildBossReward:ShowLuckyReward() local serverLevel = MDL.Player.GetServerLevel() local bossData = DataSheetManager.GuildBoss:GetDataByID(MDL.GuildBoss.ConstBossId) local rewardPool for _, v in ipairs(bossData.GuildReward_Table) do if v.minLevel <= serverLevel and serverLevel<= v.maxLevel then rewardPool = v break end end if self.LoopScroll_LeftMenu_GuildBossReward.Count > 0 then self.LoopScroll_LeftMenu_GuildBossReward:ClearCells() end if self.loop_GuildBossReward2.Count > 0 then self.loop_GuildBossReward2:ClearCells() end for _, v in ipairs(rewardPool.RewardPool) do for _, k in ipairs(DataSheetManager.GuildBossGuildRewardPool:GetDataByID(v).Item_Table) do local data = {k,DataSheetManager.GuildBossGuildRewardPool:GetDataByID(v).Type} self.LoopScroll_LeftMenu_GuildBossReward:AddData(data,0) end end if self.isCross then for _, v in DataSheetManager.GuildBossGuildRewardCrossSever:GetEnumerator() do self.loop_GuildBossReward2:AddData(v, 0) end else for _, v in DataSheetManager.GuildBossGuildReward:GetEnumerator() do self.loop_GuildBossReward2:AddData(v, 0) end end UIUtils.SetLabelText(self.txt_Tips, Const_IDS["IDS_GuildBoss_RewardDesc3"]) end function UIGuildBossReward:SetRankIcon(cell, data) if data.Rank > 0 and data.Rank <= 2 then UIUtils.SetActive(cell.section_Rank, true) cell.rank_State:SetState(data.Rank - 1) UIUtils.SetActive(cell.txt_Rank, false) else UIUtils.SetActive(cell.section_Rank, false) UIUtils.SetActive(cell.txt_Rank, true) local preRankConfig = DataSheetManager.GuildBossGuildReward:GetDataByID(data.ID - 1) if data.Rank == 0 then cell.txt_Rank.text = string.FormatByIdsId(Const_IDS.IDS_GuildBoss_RangeRankLabel3, preRankConfig.Rank) else cell.txt_Rank.text = string.FormatByIdsId(Const_IDS.IDS_GuildBoss_RangeRankLabel2, preRankConfig.Rank + 1, data.Rank) end end end function UIGuildBossReward:CreateItemObj(cellTb, index, id, num, isAuction) local obj = cellTb.content[index] if obj == nil then obj = self:InstantiateCellCollection( cellTb.cell.gameObject, cellTb.content, self.UIItem.gameObject ) UIUtils.SetActive(obj.gameObject, true) end obj.ID = id UIUtils.SetActive(obj.gameObject, true) UTL.Item.SetItemCell(obj.item, id, num) -- 锤子图标 UIUtils.SetActive(obj.img_Icon, isAuction) return obj end function UIGuildBossReward:InitRewards(cellTb, data) local index = 0 local rewardData = {} if self.selectIndex == TabInfo[TabType.guild].index then -- 势力奖励 for _, v in ipairs(DataSheetManager.GuildBossRewardOfGuild:GetDataByID(data.GuildReward).Item_Table) do local itemData = {ItemNum = v.ItemNum, ItemID = v.ItemID, isAuction = false} table.insert(rewardData, itemData) end if CTL.GuildBoss.GetIsShowAuction() and GameAppInfo.IsJapanesePackage() == false then for _, v in ipairs(MDL.GuildAuction.GetAuctionRewardsShowList(data.RewardPoolID, LuaConst.ActivityType.GuildBoss)) do table.insert(rewardData, v) end end elseif self.selectIndex == TabInfo[TabType.personal].index then -- 个人奖励 for _, v in ipairs(DataSheetManager.GuildBossRewardOfPerson:GetDataByID(data.PersonalReward).Item_Table) do local itemData = {ItemNum = v.ItemNum, ItemID = v.ItemID, isAuction = false} table.insert(rewardData, itemData) end end for _, v in ipairs(rewardData) do index = index + 1 self:CreateItemObj(cellTb, index, v.ItemID, v.ItemNum, v.isAuction) end for i = #cellTb.content, index + 1, -1 do UIUtils.SetActive(cellTb.content[i].gameObject, false) end end function UIGuildBossReward:OnBackButtonPressed() self:OnButtonClicked(self.btn_Close) end function UIGuildBossReward:OnButtonClicked(comp) if self.btn_Close == comp then self:CloseView() elseif self.btn_Info == comp then for _, v in ipairs(TabInfo) do if v.index == self.selectIndex then UIManager.OpenView(Const_UI_Lua.UIEnum.UIDescriptionPanel, { target = self.btn_Info.gameObject, posType = LuaConst.DescriptionPanelType.Center, text = UIUtils.GetLocalizedTxt(Const_IDS[v.popTip]) }) end end end end function UIGuildBossReward:OnCellInit(scrollRect, index, cellTable, data) if self.LoopScroll_LeftMenu_GuildBossReward == scrollRect then -- 幸运夺宝奖池 self:ShowRewardTag(data[2],cellTable) UTL.Item.SetItemCell(cellTable.item, data[1].ItemID, data[1].ItemNum) elseif self.LoopScroll_GuildBossReward == scrollRect then cellTable.bg_State:SetState(index % 2) -- 势力和个人奖励 self:SetRankIcon(cellTable, data) self:InitRewards(cellTable, data) elseif self.loop_GuildBossReward2 == scrollRect then -- 幸运夺宝奖励 self:SetRankIcon(cellTable, data) for i, v in ipairs(data.RewardRandomPoolNum) do -- 奖励池 cellTable.rollRewards[i].txt_Count.text = "x"..v end end end function UIGuildBossReward:OnCellClicked(scrollRect, index, cellTable, target, data) if self.LoopScroll_LeftMenu_GuildBossReward == scrollRect then UTL.ItemTips.ShowCommonTipsById(data[1].ItemID) elseif self.LoopScroll_GuildBossReward == scrollRect then for _, v in ipairs(cellTable.content) do if target == v.item.event_Click then UTL.ItemTips.ShowCommonTipsById(v.ID) break end end end end function UIGuildBossReward:ShowRewardTag(rewardTag,item) if rewardTag == MDL.GuildBoss.RewardTag.PuTong then item.obj_State:SetState(0) elseif rewardTag == MDL.GuildBoss.RewardTag.ZhenPin then item.obj_State:SetState(1) elseif rewardTag == MDL.GuildBoss.RewardTag.JiPin then item.obj_State:SetState(2) end end return UIGuildBossReward