local UIGoldenHeroStory = UIViewClass() local EventSystem = require('Event/EventSystem') function UIGoldenHeroStory:OnOpened(context) self.activityId = context.activityId self.heroType = context.heroType self.activityType = MDL.OperationActivity.ActivityType.GoldenHero self.goldHeroActivityModeData = DataSheetManager.GoldHeroActivityModeData:GetDataByHeroType(self.heroType) --标题 UIUtils.SetLabelText(self.UITemplateTitlePanel.lab_Title, Const_IDS[self.goldHeroActivityModeData.LevelName]) UIUtils.SetLocalizationImage(self.img_New, "zr_msz_new.png") self.img_New:SetNativeSize() self:RegistSystemEvent(CTL.GoldenHeroMain.RpEventId[self.activityId].Boss, self.RefreshGoldenHeroBossRp) -- 协同入口红点 self:RegistSystemEvent(CTL.GoldenHeroMain.RpEventId[self.activityId].BossNewOne, self.RefreshGoldenHeroBossRp) -- 协同入口红点 self:RegistSystemEvent(EventID.UI_OperationActivity_CloseView, self.OnCloseActivitySelf) self:RegistSystemEvent(EventID.UI_GoldenHeroStory_GoldHeroSkipAllStory, self.RefreshSkipStoryBtn) self:RegistSystemEvent(EventID.UI_LaterEnter_QuickPass, self.RefreshSkipStoryBtn) self:OpenPathPanel(context) self:RefreshGoldenHeroBossRp(MDL.RedPoint.GetNodeStateByMultiKey(CTL.GoldenHeroMain.RpEventId[self.activityId].TownHome, CTL.GoldenHeroMain.RpEventId[self.activityId].Boss)) -- 协同入口红点 local isShowEndingBtn = self.goldHeroActivityModeData.IsDisplayRecord UIUtils.SetActive(self.group_Ending, isShowEndingBtn) if isShowEndingBtn then self:RegistSystemEvent(CTL.GoldenHeroMain.RpEventId[self.activityId].StoryEndingReward, self.RefreshGoldenHeroStoryEndingRp) -- 秘闻录可领奖红点 self:RefreshGoldenHeroStoryEndingRp(MDL.RedPoint.GetNodeStateByLogicParams(CTL.GoldenHeroMain.RpEventId[self.activityId].TownHome, CTL.GoldenHeroMain.RpEventId[self.activityId].StoryEndingReward)) -- 秘闻录可领奖红点 end CTL.GoldenHeroMain.OpenCurrencyPanel(self.heroType, self.__viewClassPath, self.currency_Info, {activityType = self.activityType, activityId = self.activityId, energyType = MDL.GoldenHeroMain.EnergyType.Story, title = "IDS_DrawCard_Title_QuickBuy"}) CTL.GoldenHeroStory.SetStoryViewBossButtonNode(self.btn_Fight) self:RefreshSkipStoryBtn() end function UIGoldenHeroStory:OnCloseActivity() self:CloseView(true) end function UIGoldenHeroStory:OnClosed() UIManager.CloseView(Const_UI_Lua.UIEnum.UIGoldenHeroStoryLevelInfo) UIManager.CloseView(Const_UI_Lua.UIEnum.UIGoldenHeroStoryTaskInfo) CTL.GoldenHeroStory.SetStoryViewBossButtonNode(nil) end function UIGoldenHeroStory:OnCloseActivitySelf(viewClassPath, activityId) if viewClassPath == self.__viewClassPath then if self.activityId and activityId == self.activityId then self:CloseView(true) end end end function UIGoldenHeroStory:OnBackButtonPressed() self:OnButtonClicked(self.UITemplateTitlePanel.btn_close) end function UIGoldenHeroStory: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.UITemplateTitlePanel.btn_Info then local params = {} local levelEnergyType = self.goldHeroActivityModeData.LevelEnergyType local itemName = UIUtils.GetLocalizedTxt(Const_IDS[DataSheetManager.ItemData:GetDataByID(levelEnergyType).Name]) table.insert(params, itemName) for k,v in DataSheetManager.GoldHeroEnergyGet:GetEnumerator() do if v.Type == 1 then local _,timeStr = UTL.Time.GetDateDescAndTime({v.Time}) table.insert(params, timeStr) end end UIManager.OpenView(Const_UI_Lua.UIEnum.UICommonNoteView, {id = LuaConst.NoteID.GoldHeroStory, params = params}) elseif comp == self.btn_Ending then -- 秘闻录 UIManager.OpenView(Const_UI_Lua.UIEnum.UIGoldenHeroStoryEnding, {activityId = self.activityId, heroType = self.heroType}) elseif comp == self.btn_Fight then -- 协同讨伐 UIManager.OpenAndPushAll(Const_UI_Lua.UIEnum.UIGoldenHeroBossMain, {activityId = self.activityId, heroType = self.heroType}) elseif comp == self.btn_Skip then -- 快速跳过 UTL.MessageBox.ShowOKCancelBox(nil, Const_IDS.IDS_GoldHeroActivityJump_1, function() MDL.GoldenHeroStory.GoldHeroSkipAllStoryReq(self.activityId) end) elseif comp == self.btn_QuickSkip then --一键速通 MDL.LaterEnter.LaterEnterQuickPassReq(MDL.LaterEnter.LaterEnterQuickPassType.GoldHeroActivity, {self.activityId}) end end ---@public 打开路线图界面 function UIGoldenHeroStory:OpenPathPanel(contextData) if contextData.levelId then local levelCfg = DataSheetManager.GoldHeroActivityLevel:GetDataByID(contextData.levelId) local levelState = MDL.GoldenHeroStory.GetGoldHeroLevelStateByActivityID_LevelID(self.activityId, levelCfg.ID) -- 关卡状态 self.storyLevelInfo = {levelCfg = levelCfg, levelState = levelState} end if contextData.taskId then local taskCfg = DataSheetManager.GoldHeroActivityTask:GetDataByTaskID(contextData.taskId) local taskState = MDL.GoldenHeroStory.GetTaskStateByActivityID_HeroType_TaskFatherID(self.activityId, self.heroType, taskCfg.TaskID) self.storyTaskInfo = {taskCfg = taskCfg, taskState = taskState} end self.pathView:CloseAll() self.pathView:OpenView(GetViewClass(Const_UI_Lua.UIEnum.UIGoldenHeroStoryPath), {parentView = self}, self.goldHeroActivityModeData.ModePrefab) if self.storyTaskInfo then -- 传入taskID就直接打开任务详情界面 self:ChangeSunUIPanel(0, self.storyTaskInfo) end if self.storyLevelInfo then -- 传入levelID就直接打开关卡详情界面 self:ChangeSunUIPanel(1, self.storyLevelInfo) end end ---@public 打开任务或关卡详情界面 function UIGoldenHeroStory:ChangeSunUIPanel(subPanelID, taskOrLevel_Data) UIManager.CloseView(Const_UI_Lua.UIEnum.UIGoldenHeroStoryLevelInfo) UIManager.CloseView(Const_UI_Lua.UIEnum.UIGoldenHeroStoryTaskInfo) if subPanelID == 0 then UIManager.OpenView(Const_UI_Lua.UIEnum.UIGoldenHeroStoryTaskInfo, {activityId = self.activityId, heroType = self.heroType, storyTaskInfo = taskOrLevel_Data}) elseif subPanelID == 1 then UIManager.OpenView(Const_UI_Lua.UIEnum.UIGoldenHeroStoryLevelInfo, {activityId = self.activityId, heroType = self.heroType, storyLevelInfo = taskOrLevel_Data}) end end function UIGoldenHeroStory:OnFocusChanged(isFocus) if isFocus then CTL.GoldenHeroMain.SetGoldenHeroFocusTarget(Const_UI_Lua.UIEnum.UIGoldenHeroStory, self.activityId) EventSystem.Dispatch(EventID.UI_GoldenHero_FocusOnGoldenHeroView, Const_UI_Lua.UIEnum.UIGoldenHeroStory, self.activityId) else CTL.GoldenHeroMain.SetGoldenHeroFocusTarget(nil, nil) end end ---@public 秘闻录入口红点 function UIGoldenHeroStory:RefreshGoldenHeroStoryEndingRp(active) self.btn_Ending:SetRedPoint(active) end ---@public 协同讨伐入口红点 function UIGoldenHeroStory:RefreshGoldenHeroBossRp(active) if CTL.GoldenHeroBoss.CheckIfHasNewBoss(self.activityId) then UIUtils.SetActive(self.img_New, true) self.btn_Fight:SetRedPoint(false) else UIUtils.SetActive(self.img_New, false) self.btn_Fight:SetRedPoint(active) end end function UIGoldenHeroStory:RefreshSkipStoryBtn() local isCanSkip = MDL.GoldenHeroStory.IsCanSkipLevel(self.activityId) local isCompleteAllEnd = MDL.GoldenHeroStory.IsUnclockAllEndingByActivityID(self.activityId) if isCanSkip and not isCompleteAllEnd then UIUtils.SetActive(self.btn_Skip, true) else UIUtils.SetActive(self.btn_Skip, false) local isCanQuickSkip = MDL.LaterEnter.IsCanQuickSkip(MDL.LaterEnter.LaterEnterQuickPassType.GoldHeroActivity) UIUtils.SetActive(self.btn_QuickSkip, isCanQuickSkip and not isCompleteAllEnd) end end return UIGoldenHeroStory