local UIGoldenHeroStoryOption = UIViewClass() function UIGoldenHeroStoryOption:OnOpened(context) self:RegistSystemEvent(EventID.UI_OperationActivity_CloseView, self.OnCloseActivitySelf) self.storyOptionQueue ={} self.taskChildData = context.taskChildData self.activityId = MDL.GoldenHeroStory.GetActivityIDByTaskLineID(context.taskChildData.TaskLineID) self:Start(context.taskChildData, context.callback, context.entity) UIManager.ActiveUIModle(false, "UIGoldenHeroStoryOption") end function UIGoldenHeroStoryOption:OnCloseActivitySelf(viewClassPath, activityId) if viewClassPath == self.__viewClassPath then if self.activityId and activityId == self.activityId then self:Finish() end end end function UIGoldenHeroStoryOption:OnClosed() self.storyOptionQueue =nil self.curStoryOption = nil UIManager.SetLayerActive(Const_UI_Lua.UILayers.UIForeground, false) UIManager.ActiveUIModle(true, "UIGoldenHeroStoryOption") end --region 选项按钮相关 function UIGoldenHeroStoryOption:OnButtonClicked(comp) if comp==self.btn_Option1 then local isFinishTask = MDL.Task.GetCompletedTaskByID(tonumber(self.curStoryOption.button1.func[2])) local btn1TaskInfo = MDL.Task.GetTask(tonumber(self.curStoryOption.button1.func[2])) local btn2TaskInfo = MDL.Task.GetTask(tonumber(self.curStoryOption.button2.func[2])) if isFinishTask then UIManager.SetLayerActive(Const_UI_Lua.UILayers.UIForeground, true) CTL.Tips.AddTipsMsg(Const_IDS["IDS_GoldHeroActivity_ActivityLevel_BranchHint3"]) if btn1TaskInfo or btn2TaskInfo then self:Finish() end else if btn2TaskInfo then CTL.Tips.AddTipsMsg(Const_IDS["IDS_GoldHeroActivity_ActivityLevel_BranchHint3"]) self:Finish() else self:OnButtonFunction(self.curStoryOption.button1, self.curStoryOption.callback) end end elseif comp==self.btn_Option2 then local isFinishTask = MDL.Task.GetCompletedTaskByID(tonumber(self.curStoryOption.button2.func[2])) local btn1TaskInfo = MDL.Task.GetTask(tonumber(self.curStoryOption.button1.func[2])) local btn2TaskInfo = MDL.Task.GetTask(tonumber(self.curStoryOption.button2.func[2])) if isFinishTask then UIManager.SetLayerActive(Const_UI_Lua.UILayers.UIForeground, true) CTL.Tips.AddTipsMsg(Const_IDS["IDS_GoldHeroActivity_ActivityLevel_BranchHint3"]) if btn1TaskInfo or btn2TaskInfo then self:Finish() end else if btn1TaskInfo then CTL.Tips.AddTipsMsg(Const_IDS["IDS_GoldHeroActivity_ActivityLevel_BranchHint3"]) self:Finish() else self:OnButtonFunction(self.curStoryOption.button2, self.curStoryOption.callback) end end end end function UIGoldenHeroStoryOption:OnButtonFunction(button, callback) self:Finish() -- 这里先调用回调函数是因为,回调里是完成当前任务的逻辑,点击button的行为是要接下个任务链 if callback then callback(self.taskChildData.TaskLineID) callback = nil end if button.func then -- 这里是要手动接后面的任务链 self:DoButtonFunction(unpack(button.func)) end end function UIGoldenHeroStoryOption:DoButtonFunction(funcName,...) if funcName then local buttonFunc = CTL.Dialogue[funcName] if not buttonFunc then return end buttonFunc(...) end end function UIGoldenHeroStoryOption:Finish() AuxUtil.StopTimeline() UIManager.CloseSpecialView(Const_UI_Lua.UIEnum.UIGoldenHeroStoryOption) CameraController.Instance:SetTalkSystem(false, nil) end --endregion function UIGoldenHeroStoryOption:Start(taskChildData, callback, entity) local option = {} option.entity = entity 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 UIGoldenHeroStoryOption: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 UIGoldenHeroStoryOption:Show(dialogue, first) if first then if dialogue.entity then CameraController.Instance:SetTalkSystem(true, dialogue.entity.ExpEntity:GetRenderEntity()) end end local task1IsOpenOrFinish = MDL.Task.GetCompletedTaskByID(tonumber(dialogue.button1.func[2])) local task2IsOpenOrFinish = MDL.Task.GetCompletedTaskByID(tonumber(dialogue.button2.func[2])) if dialogue.button1 then self.state_BtnSelect1:SetState(task1IsOpenOrFinish and 1 or 0) UIUtils.SetLabelText(self.txt_Option1,Const_IDS[dialogue.button1.name]) end if dialogue.button2 then self.state_BtnSelect2:SetState(task2IsOpenOrFinish and 1 or 0) UIUtils.SetLabelText(self.txt_Option2,Const_IDS[dialogue.button2.name]) end end return UIGoldenHeroStoryOption