local UITeamPVE = UIViewClass() local awardTotalTimes function UITeamPVE:OnOpened(dungeonData) self:RegistSystemEvent(EventID.UI_TeamMatch_MatchTime, self.OnMatchExpression) self:RegistSystemEvent(EventID.UI_TeamDungeon_RefreshAwardCount, self.RefreshRewardTimes) self:RegistSystemEvent(EventID.UI_Team_MemberInfoChange, self.RefreshTeamInfo) self.dungeonData = dungeonData self:SetConfigInfo(dungeonData) self:RefreshRewardTimes() local isMatching = CTL.TeamMatch.IsActivityMatchingById(dungeonData.ActivityID) self:UpdateTimer(isMatching) CTL.TeamDungeon.SetUIActivityId(dungeonData.ActivityID) end function UITeamPVE:SetConfigInfo(dungeonData) local rewardData = MDL.TeamDungeon.GetCurTeamDungeonReward(dungeonData) if rewardData then local cfg = DataSheetManager.RewardClientShow:GetDataByClientShowID(rewardData.RewardClientShowID) local levelRewardTable = DataSheetUtil.GetRewardClientShowItemTable(cfg) for _,v in ipairs(levelRewardTable) do self.ItemScrollView:AddData(v, 0) end end -- 设置标题 UIUtils.SetLabelText(self.txt_DungeonInfo, Const_IDS[dungeonData.DungeonDes]) UIUtils.SetLabelText(self.txt_DungeonName, Const_IDS[dungeonData.DungeonName]) UIUtils.SetLabelText(self.UITemplateTitlePanel.lab_Title, Const_IDS[dungeonData.Title]) local activityData = DataSheetManager.ActivityData:GetDataByID(dungeonData.ActivityID) if activityData then awardTotalTimes = activityData.DailyRefreshTimes end UIUtils.SetTextureByAssetBundle(self.img_TeamPVEBg, dungeonData.BackgroundPicture) UIUtils.SetTextureByAssetBundle(self.img_Map, dungeonData.MiniMapPicture) self:RefreshTeamInfo() end function UITeamPVE:RefreshTeamInfo() local playerNum = self.dungeonData.PlayerNum local teamMemberNum = MDL.Team.GetTeamMemberNumbers() teamMemberNum = teamMemberNum == 0 and 1 or teamMemberNum UIUtils.SetLabel(self.txt_TeamNum, string.format("%s/%s", teamMemberNum, playerNum)) --根据队伍人数、匹配状态变更按钮文字 if CTL.TeamMatch.IsActivityMatchingById(self.dungeonData.ActivityID) then self.btn_Match:SetText(Const_IDS.IDS_TeamDungeon1_Button_CancelMatch) else UIUtils.SetLabelText(self.txt_Enter, Const_IDS["IDS_TeamDungeon1_Start"]) UIUtils.SetLabelText(self.txt_Match, Const_IDS["IDS_TeamDungeon1_Button_Match"]) UIUtils.SetActive(self.txt_Enter, teamMemberNum >= playerNum) UIUtils.SetActive(self.txt_Match, teamMemberNum < playerNum) end end function UITeamPVE:RefreshRewardTimes() local leftCount = MDL.TeamDungeon.LeftAwardCountDic and MDL.TeamDungeon.LeftAwardCountDic[self.dungeonData.ID] or awardTotalTimes UIUtils.SetLabel(self.txt_TimesNum,leftCount > 0 and string.format("%s/%s",UTL.Color.FormatGreenColor(leftCount),awardTotalTimes) or string.format("%s/%s",UTL.Color.FormatRedColor(leftCount),awardTotalTimes)) end function UITeamPVE:OnClickMatch() local activityId = self.dungeonData.ActivityID local state = CTL.TeamMatch.GetMatchOperationStateByActivityId(activityId) local leftCount = MDL.TeamDungeon.LeftAwardCountDic and MDL.TeamDungeon.LeftAwardCountDic[self.dungeonData.ID] or awardTotalTimes if state then if state ~= CTL.TeamMatch.MatchOperationState.CancelMatch and leftCount == 0 then UTL.MessageBox.ShowOKCancelBox(nil, UIUtils.GetLocalizedTxt(Const_IDS["IDS_TeamDungeon1_NoReward"]), function() CTL.TeamMatch.OnPressMatchButton(activityId, CTL.TeamDungeon.DealWithTeamPVEMatch) end) else CTL.TeamMatch.OnPressMatchButton(activityId, CTL.TeamDungeon.DealWithTeamPVEMatch) end else CTL.Sound.PlayGameSound("UI_invalid") end end function UITeamPVE:OnBackButtonPressed() self:OnButtonClicked(self.UITemplateTitlePanel.btn_close) end function UITeamPVE:OnButtonClicked(comp) if comp == self.UITemplateTitlePanel.btn_close then self:CloseView(true) elseif comp == self.UITemplateTitlePanel.btn_Home then CTL.HomeMain.CloseViewBackHomeMain() elseif comp == self.btn_RewardInfo then CTL.TeamDungeon.OpenRewardPreviewPanel(self.dungeonData.ID) elseif comp == self.btn_Team then CTL.Team.OpenTeamPanel(self.dungeonData.ActivityID) elseif comp == self.btn_Match then self:OnClickMatch() elseif comp == self.UITemplateTitlePanel.btn_Info then local GuidanceID = self.dungeonData.GuidanceNotesID local timeStr = UTL.Time.GetDiffLocalStrById(1) UIManager.OpenView(Const_UI_Lua.UIEnum.UICommonNoteView, {id = GuidanceID, params = {timeStr}}) elseif comp == self.btn_Shop then --店铺 UIManager.OpenAndPushAll(Const_UI_Lua.UIEnum.UIShopMain, {TabEnum = CTL.PayMall.ShopMainTabEnum.ZuDui}) end end function UITeamPVE:OnMatchExpression(state) if CTL.TeamMatch.IsActivityMatchingById(self.dungeonData.ActivityID) then self:UpdateTimer(state) else self:UpdateTimer(false) end end function UITeamPVE:UpdateTimer(state) if state then local maxTime = MDL.TeamDungeon.GetMaxMatchTime() local durTime = UTL.Time.GetServerTimestamp() - MDL.TeamMatch.GetStartMatchingTime() self.cdTimer:SetAndContinueTimer(true, durTime, maxTime) self.btn_Match:SetText(Const_IDS.IDS_TeamDungeon1_Button_CancelMatch) self.effect_Matching:PlayUIEffect() else self.cdTimer:EndTimer() self.btn_Match:SetText(Const_IDS.IDS_TeamDungeon1_Button_Match) self.effect_Matching:StopUIEffect() end end function UITeamPVE:OnClosed() CTL.TeamDungeon.ClearUIActivityId() self.cdTimer:EndTimer() end function UITeamPVE:OnCellInit(scrollRect, index, cellTable, data) UTL.Item.SetItemCell(cellTable.UIItem, data.ItemID, data.ItemNum) end function UITeamPVE:OnCellClicked(scrollRect, index, cellTable, target, data) UTL.ItemTips.ShowCommonTipsById(data.ItemID) end return UITeamPVE