local UIHeroMatch1v1Reward = UIViewClass() local TAB_INDEX = { ShowHero = 0, Match_1 = 1, Filtration = 3, } local CRYOPHOENIX_ID = 10014 local PHOENIX_ID = 10013 local rewardsTabData = { [1] = { ID = 5, name = UIUtils.GetLocalizedTxt(Const_IDS["IDS_HeroMatch1v1_Award1"]) }, [2] = { ID = 4, name = UIUtils.GetLocalizedTxt(Const_IDS["IDS_HeroMatch1v1_Award2"]) }, [3] = { ID = 3, name = UIUtils.GetLocalizedTxt(Const_IDS["IDS_HeroMatch1v1_Award3"]) }, [4] = { ID = 2, name = UIUtils.GetLocalizedTxt(Const_IDS["IDS_HeroMatch1v1_Award4"]) }, } function UIHeroMatch1v1Reward:OnOpened(context) self:InitPanel() end function UIHeroMatch1v1Reward:InitPanel() self:RegistSystemEvent(EventID.UI_HeroMatch1v1_CloseView, self.OnBackButtonPressed) -- 赛程结束关闭界面 self:RegistSystemEvent(EventID.UI_HeroMatch1v1_RefreshInfo, self.RefreshPanel) -- 赛程结束关闭界面 self.appearanceID1 = PHOENIX_ID self.appearanceID2 = CRYOPHOENIX_ID self.clickedTabIndex = 0 self:RefreshPanel() self.state_3V3:SetState(0) end function UIHeroMatch1v1Reward:RefreshPanel() self:RefreshTabs() self:SetMyRank() end function UIHeroMatch1v1Reward:SetMyRank() -- 设置我的排名 self.myRankDesc, self.myRank = CTL.HeroMatch1v1.GetMyCurRankInfoDesc() self.myMatchInfo = MDL.HeroMatch1v1.GetMyMatchInfo() UIUtils.SetLabel(self.txt_Rank, UIUtils.GetLocalizedTxt(Const_IDS["IDS_Chat_BestRank"])..self.myRankDesc) end function UIHeroMatch1v1Reward:RefreshTabs() self.loop_LeftTab:ReloadAll(rewardsTabData) self.loop_LeftTab:SelectIndex(self.clickedTabIndex) end function UIHeroMatch1v1Reward:OnBackButtonPressed() self:OnButtonClicked(self.btn_Close) end function UIHeroMatch1v1Reward:OnButtonClicked(comp) if comp == self.btn_Close then self:CloseView() elseif comp == self.btn_TipClose then self:ShowHideTips(false) elseif comp == self.btn_Info then self:ShowHideTips(true) elseif comp == self.btn_Info_Appearance1 then UIManager.OpenAndPushAll(Const_UI_Lua.UIEnum.UICharacterTeamChangeImage, {openIndex = 3, openID = self.appearanceID1}) elseif comp == self.btn_Info_Appearance2 then UIManager.OpenAndPushAll(Const_UI_Lua.UIEnum.UICharacterTeamChangeImage, {openIndex = 3, openID = self.appearanceID2}) elseif comp == self.btn_PointReward then -- 商店跳转 UIManager.OpenView(Const_UI_Lua.UIEnum.UIHeroMatch1v1Store) end end function UIHeroMatch1v1Reward:ShowHideTips(isShow) UIUtils.SetActive(self.group_RewardInfo, isShow) UIUtils.SetActive(self.btn_TipClose, isShow) end function UIHeroMatch1v1Reward:GetRewardConfig(rewardId) return DataSheetManager.MatchStageScreenRewardRepeat:GetDataByAttrRepeatID(rewardId).Item_Table end function UIHeroMatch1v1Reward:OnCellInit(scrollRect, index, cellTable, data) if scrollRect == self.loop_LeftTab then UIUtils.SetActive(cellTable.group_Selected.gameObject, self.clickedTabIndex == index) UIUtils.SetActive(cellTable.group_UnSelected.gameObject, self.clickedTabIndex ~= index) UIUtils.SetLabel(cellTable.txt_UnselectedTabName, data.name) UIUtils.SetLabel(cellTable.txt_SelectedTabName, data.name) elseif scrollRect == self.loop_HMReward then if self:IsFiltrationTab(self.clickedTabIndex) then -- 筛选赛 cellTable.UIState_Rank:SetState(2) if data.RankIndex == 0 then UIUtils.SetLabelText(cellTable.txt_Rank, Const_IDS["IDS_HeroMatch1v1_JoinReward"]) else UIUtils.SetLabel(cellTable.txt_Rank, string.FormatByIdsId(Const_IDS["IDS_HeroMatch1v1_NowResult1"], data.RankIndex)) end -- 道具奖励显示 local rewards = self:GetRewardConfig(data.RewardID) self:SetRewardItems(cellTable.group_Reward, rewards) else if self:IsMatch1Tab(self.clickedTabIndex) then -- 冠军赛 if index == 0 then cellTable.UIState_Rank:SetState(0) UIUtils.SetLabelText(cellTable.txt_Rank01, Const_IDS["IDS_HeroMatch1v1_NowResult4"]) elseif index == 1 then UIUtils.SetLabelText(cellTable.txt_Rank02, Const_IDS["IDS_HeroMatch1v1_NowResult3"]) cellTable.UIState_Rank:SetState(1) else cellTable.UIState_Rank:SetState(2) local count = self:GetPlayerRewardCount(data.ID) UIUtils.SetLabel(cellTable.txt_Rank, string.FormatByIdsId(Const_IDS["IDS_HeroMatch1v1_NowResult2"], count)) end else -- 排位赛 cellTable.UIState_Rank:SetState(2) local count = self:GetPlayerRewardCount(data.ID, index) UIUtils.SetLabel(cellTable.txt_Rank, string.FormatByIdsId(Const_IDS["IDS_HeroMatch1v1_NowResult2"], count)) end local rewards = self:GetRewardConfig(data.RewardID) self:SetRewardItems(cellTable.group_Reward, rewards) end end end function UIHeroMatch1v1Reward:GetPlayerRewardCount(stage, index) local curCfg, lastCfg for i,v in DataSheetManager.TeamMatchStage:GetEnumerator() do if v.ID == stage then curCfg = v break end lastCfg = v end if curCfg and lastCfg then if index == 0 then return string.format("%d-%d", 1, curCfg.PlayerNum * 2) else return string.format("%d-%d", lastCfg.PlayerNum * 2 + 1, curCfg.PlayerNum * 2) end end end function UIHeroMatch1v1Reward:OnCellClicked(scrollRect, index, cellTable, target, data) if scrollRect == self.loop_HMReward then -- 道具奖励预览 for idx, v in ipairs(cellTable.group_Reward) do if target == v.event_Click then local rewards = self:GetRewardConfig(data.RewardID) UTL.ItemTips.ShowCommonTipsById(rewards[idx].ItemID) return end end end end function UIHeroMatch1v1Reward:OnCellSelect(scrollRect, index, cellTable, data) if scrollRect == self.loop_LeftTab then local lastClick = self.clickedTabIndex self.clickedTabIndex = index self.loop_LeftTab:UpdateIndex(lastClick) UIUtils.SetActive(self.group_Reward01.gameObject, false) UIUtils.SetActive(self.group_Reward02.gameObject, false) if index == TAB_INDEX.ShowHero then -- 4强奖励展示 self:ShowHeroRewards(data) elseif index >= TAB_INDEX.Filtration then self:ShowFilterRewards(data) else self:ShowRankRewards(data) end end end function UIHeroMatch1v1Reward:ShowHeroRewards(data) UIUtils.SetActive(self.group_Reward01.gameObject, true) end function UIHeroMatch1v1Reward:ShowFilterRewards(data) UIUtils.SetActive(self.group_Reward02.gameObject, true) UIUtils.SetLabelText(self.txt_Title1, Const_IDS["IDS_HeroMatch1v1_WinNum"]) UIUtils.SetLabelText(self.txt_Title2, Const_IDS["IDS_HeroMatch1v1_GotAward"]) UIUtils.SetLabelText(self.lab_Info, Const_IDS["IDS_HeroMatch1v1_RewardTips"]) self.loop_HMReward:ReloadAll(CTL.HeroMatch1v1.GetRankRewardsDataByMatchTimeID(data.ID, true)) end function UIHeroMatch1v1Reward:ShowRankRewards(data) UIUtils.SetActive(self.group_Reward02.gameObject, true) UIUtils.SetLabelText(self.txt_Title1, Const_IDS["IDS_HeroMatch1v1_WinNum2"]) UIUtils.SetLabelText(self.txt_Title2, Const_IDS["IDS_HeroMatch1v1_GotAward"]) UIUtils.SetLabelText(self.lab_Info, Const_IDS["IDS_HeroMatch1v1_GotAwardMail"]) self.loop_HMReward:ReloadAll(CTL.HeroMatch1v1.GetRankRewardsDataByMatchTimeID(data.ID)) end function UIHeroMatch1v1Reward:SetRewardItems(col, rewards) for i, v in ipairs(col) do if i <= #rewards then UIUtils.SetActive(v.gameObject, true) UTL.Item.SetItemCell(v, rewards[i].ItemID, rewards[i].ItemNum) else UIUtils.SetActive(v.gameObject, false) end end end function UIHeroMatch1v1Reward:IsFiltrationTab(index) return index >= TAB_INDEX.Filtration end function UIHeroMatch1v1Reward:IsMatch1Tab(index) return index == TAB_INDEX.Match_1 end return UIHeroMatch1v1Reward