local UISuperGoldStoryOption = UIViewClass() function UISuperGoldStoryOption:OnOpened(context) self:RegistSystemEvent(EventID.UI_OperationActivity_CloseView, self.OnCloseActivitySelf) self:RegistSystemEvent(EventID.HomeMain_TimeLineActive, self.OnCloseChangeScene) self.curTaskInfo = context.taskChildData self.activityId = MDL.SuperGoldStory.GetActivityIDByTaskLineID(self.curTaskInfo.TaskLineID) self.heroType = MDL.SuperGoldMain.GetHeroTypeByActivityId(self.activityId) self.storyOptionQueue ={} self:Start(context.taskChildData, context.callback) self.taskChildData = context.taskChildData UIManager.ActiveUIModle(false, "UISuperGoldStoryOption") end function UISuperGoldStoryOption:OnCloseActivitySelf(viewClassPath, activityId) if viewClassPath == self.__viewClassPath then if self.activityId and activityId == self.activityId then self:Finish() end end end function UISuperGoldStoryOption:OnCloseChangeScene(value, allOpen) if value == true and allOpen == true then self.storyOptionQueue =nil self.curStoryOption = nil UIManager.ActiveUIModle(true, "UISuperGoldStoryOption") UIManager.CloseSpecialView(Const_UI_Lua.UIEnum.UISuperGoldStoryOption) end end --region 选项按钮相关 function UISuperGoldStoryOption:OnButtonClicked(comp) if comp==self.btn_Option1 then local btn1TaskInfo = MDL.Task.GetTask(tonumber(self.curStoryOption.button1.func[2])) if btn1TaskInfo then self:Finish() else self:OnButtonFunction(self.curStoryOption.button1, self.curStoryOption.callback) end elseif comp==self.btn_Option2 then local btn2TaskInfo = MDL.Task.GetTask(tonumber(self.curStoryOption.button2.func[2])) if btn2TaskInfo then self:Finish() else self:OnButtonFunction(self.curStoryOption.button2, self.curStoryOption.callback) end end end function UISuperGoldStoryOption:OnButtonFunction(button, callback) local hasEndingCount = MDL.SuperGoldStory.CheckHaveOpenEndingCount(self.activityId, self.heroType) local isOpenAll = MDL.SuperGoldStory.CheckOpenAllEnding(self.activityId, self.heroType) if hasEndingCount or isOpenAll then self:Finish() -- 这里先调用回调函数是因为,回调里是完成当前任务的逻辑,点击button的行为是要接下个任务链 if callback then callback(self.taskChildData.TaskLineID) callback = nil end if button.func then -- 这里是要手动接后面的任务链 self:DoButtonFunction(unpack(button.func)) end else -- 当前已无可解锁的新结局,是否继续开启该任务? UTL.MessageBox.ShowOKCancelBox(Const_IDS["IDS_COMMON_PROMPT"], UIUtils.GetLocalizedTxt(Const_IDS.IDS_SuperGoldHeroActivity_Level_OpenTaskHint_5), function () self:Finish() -- 这里先调用回调函数是因为,回调里是完成当前任务的逻辑,点击button的行为是要接下个任务链 if callback then callback(self.taskChildData.TaskLineID) callback = nil end if button.func then -- 这里是要手动接后面的任务链 self:DoButtonFunction(unpack(button.func)) end end, nil, Const_IDS.IDS_SuperGoldHeroActivity_Level_Button_7, Const_IDS.IDS_SuperGoldHeroActivity_Level_Button_6 ) end end function UISuperGoldStoryOption:DoButtonFunction(funcName,...) if funcName then local buttonFunc = CTL.Dialogue[funcName] if not buttonFunc then return end buttonFunc(...) end end function UISuperGoldStoryOption:Finish() AuxUtil.StopTimeline() CameraController.Instance:SetTalkSystem(false, nil) end --endregion function UISuperGoldStoryOption:Start(taskChildData, callback) local option = {} option.callback = callback if taskChildData then if not string.isNilOrEmpty(taskChildData.Func1Name) then option.button1 = {} option.button1.func = taskChildData.Func1 option.button1.name = taskChildData.Func1Name end if not string.isNilOrEmpty(taskChildData.Func2Name) then option.button2 = {} option.button2.func = taskChildData.Func2 option.button2.name = taskChildData.Func2Name end end self:Begin(option) end function UISuperGoldStoryOption:Begin(dialogue) if not self.curStoryOption then UIUtils.SetActive(self.gameObject,true) self.curStoryOption = dialogue self:Show(dialogue,true) else table.insert(self.storyOptionQueue,dialogue) end end function UISuperGoldStoryOption:Show(dialogue) if dialogue.button1 then self.state_BtnSelect1:SetState(MDL.SuperGoldStory.GetTaskLineIsDone(self.activityId, self.heroType, tonumber(dialogue.button1.func[2])) and 0 or 1) UIUtils.SetLabelText(self.txt_Option1,Const_IDS[dialogue.button1.name]) end if dialogue.button2 then self.state_BtnSelect2:SetState(MDL.SuperGoldStory.GetTaskLineIsDone(self.activityId, self.heroType, tonumber(dialogue.button2.func[2])) and 0 or 1) UIUtils.SetLabelText(self.txt_Option2,Const_IDS[dialogue.button2.name]) end end return UISuperGoldStoryOption