local UIDigTreasureIntroduction = UIViewClass() local ActivityId = 8001 local JapanActivityId = 108001 function UIDigTreasureIntroduction:OnOpened(context) self:RegistSystemEvent(EventID.UI_Team_CreateTeam, self.OnTeamCreate) self:RegistSystemEvent(EventID.UI_Team_MemberInfoChange, self.OnTeamRefresh) self:RegistSystemEvent(EventID.UI_Team_LeaveTeam, self.OnTeamRefresh) local showId = ActivityId if GameAppInfo.IsJapanesePackage() then showId = JapanActivityId end local cfg = DataSheetManager.RewardClientShow:GetDataByClientShowID(showId) local rewardData = DataSheetUtil.GetRewardClientShowItemTable(cfg) for i, v in ipairs(rewardData) do self.scroll_RewardCurrent:AddData(v, 0) end if CTL.Team.IsInTeam() then self.event_TeamUp:SetText(Const_IDS.IDS_TeamUI_MyTeam) local teamMemberNum = MDL.Team.GetTeamMemberNumbers() teamMemberNum = teamMemberNum == 0 and 1 or teamMemberNum UIUtils.SetLabel(self.txt_Members, string.FormatByIdsId(Const_IDS.IDS_DigTreasure_TreasureCave_TeamNum, teamMemberNum)) else self.event_TeamUp:SetText(Const_IDS.IDS_DigTreasure_TreasureCave_Team) UIUtils.SetLabel(self.txt_Members,"") end local task = nil local taskList = MDL.Task.GetTaskList(MDL.Task.Enum_TaskType.TreasureCave) if taskList and next(taskList) then for k, v in pairs(taskList) do task = v end end if task.TaskData.IsOrder and task.taskInfo.childInfo[1].expireTime > 0 then local timeValue = task.taskInfo.childInfo[1].expireTime - UTL.Time.GetServerTimestamp() if timeValue > 0 then local str = UIUtils.GetLocalizedTxt(Const_IDS.IDS_DigTreasure_TreasureCave_Countdown) self.txt_TimeLeft:ResetAndBeginCustomTimer(false, timeValue, 0, string.format(str, "{0}:{1}")) self:StartRepeatFunc(self.OnUpdateFun, timeValue) else self:CloseView() end end self:SetExtraRewardInfo() end function UIDigTreasureIntroduction:OnTeamCreate() UIManager.OpenAndPushAll(Const_UI_Lua.UIEnum.UITeamBasePanel) end function UIDigTreasureIntroduction:OnUpdateFun(deltaTime, time) self:CloseView() end function UIDigTreasureIntroduction:OnTeamRefresh() if CTL.Team.IsInTeam() then self.event_TeamUp:SetText(Const_IDS.IDS_TeamUI_MyTeam) local teamMemberNum = MDL.Team.GetTeamMemberNumbers() teamMemberNum = teamMemberNum == 0 and 1 or teamMemberNum UIUtils.SetLabel(self.txt_Members, string.FormatByIdsId(Const_IDS.IDS_DigTreasure_TreasureCave_TeamNum, teamMemberNum)) else self.event_TeamUp:SetText(Const_IDS.IDS_DigTreasure_TreasureCave_Team) end end function UIDigTreasureIntroduction:OnBackButtonPressed() self:OnButtonClicked(self.btn_Close) end function UIDigTreasureIntroduction:OnButtonClicked(comp) if comp == self.btn_Close then self:CloseView() elseif comp == self.event_TeamUp then if CTL.Team.IsInTeam() then CTL.Team.OpenTeamPanel(LuaConst.ActivityType.TreasureDungeon) else UIManager.OpenView(Const_UI_Lua.UIEnum.UITeamCreatePanel, { mainTarget = LuaConst.ActivityType.TreasureDungeon }) end elseif comp == self.event_MissionStart then if CTL.Team.IsInTeam() then --日服队伍不满三人提示 if GameAppInfo.IsJapanesePackage() and not CTL.Team.IsTeamFull() then UTL.MessageBox.ShowOKCancelBox(nil, Const_IDS.IDS_JP_DigTreasure_Tips, function() CTL.Team.EnterSingleTreasure(self.context.doorId) end, function() UIManager.OpenView(Const_UI_Lua.UIEnum.UITeamCreatePanel, { mainTarget = LuaConst.ActivityType.TreasureDungeon }) end, Const_IDS.IDS_DigTreasure_StillIn, Const_IDS.IDS_DigTreasure_GoToTeam) else --其他情况直接进入 CTL.Team.EnterTeamTreasure(self.context.doorId) end else --日服 特殊处理,单人或者不满3人 也可以进入组队副本,修改提示 if GameAppInfo.IsJapanesePackage() then UTL.MessageBox.ShowOKCancelBox(nil, Const_IDS.IDS_JP_DigTreasure_Tips, function() CTL.Team.EnterSingleTreasure(self.context.doorId) end, function() UIManager.OpenView(Const_UI_Lua.UIEnum.UITeamCreatePanel, { mainTarget = LuaConst.ActivityType.TreasureDungeon }) end, Const_IDS.IDS_DigTreasure_StillIn, Const_IDS.IDS_DigTreasure_GoToTeam) else --其他情况 进入单人组队 UTL.MessageBox.ShowOKCancelBox(nil, Const_IDS.IDS_DigTreasure_ConfirmTeam, function() UIManager.OpenView(Const_UI_Lua.UIEnum.UITeamCreatePanel, { mainTarget = LuaConst.ActivityType.TreasureDungeon }) end, function() CTL.Team.EnterSingleTreasure(self.context.doorId) end, Const_IDS.IDS_DigTreasure_GoToTeam, Const_IDS.IDS_DigTreasure_StillIn) end end elseif comp == self.btn_Info then UIManager.OpenView(Const_UI_Lua.UIEnum.UICommonNoteView, {id = LuaConst.NoteID.TreasureCave}) end end function UIDigTreasureIntroduction:OnCellInit(scrollRect, index, cellTable, data) UTL.Item.SetItemCell(cellTable.item, data.ItemID, data.ItemNum, data.FristGothrough, data.TagType) end function UIDigTreasureIntroduction:OnCellClicked(scrollRect, index, cellTable, target, data) local itemInfo = data UTL.ItemTips.ShowCommonTipsById(itemInfo.ItemID, true, false) end function UIDigTreasureIntroduction:OnValueChanged(comp, state) if comp == self.toggle_extra then local info = MDL.Task.GetTreasureRewardInfo() if state ~= info.isOpenSwitch then MDL.Task.ChangeDigTreasureSwitchReq(state) end end end function UIDigTreasureIntroduction:SetExtraRewardInfo() local info = MDL.Task.GetTreasureRewardInfo() local extraRewardCount = info.rewardCountLeft local extraTotalCount = DataSheetManager.ConstData:GetDataByID("DigTreasureDailyHelpTimes").IntValue local numLabel = extraRewardCount .. "/" .. extraTotalCount if extraRewardCount > 0 then self.toggle_extra.isOn = info.isOpenSwitch UIUtils.SetLabel(self.txt_num, numLabel) UIUtils.SetActive(self.group_ExtraRewardNum.gameObject, true) else UIUtils.SetActive(self.group_ExtraRewardNum.gameObject, false) end end return UIDigTreasureIntroduction