local EventSystem = require('Event/EventSystem') local UIGoldenHeroStoryTaskInfo = UIViewClass() function UIGoldenHeroStoryTaskInfo:OnOpened(context) self.activityId = context.activityId self.heroType = context.heroType self.storyTaskCfg = context.storyTaskInfo.taskCfg self.state = context.storyTaskInfo.taskState self:RegistSystemEvent(EventID.UI_OperationActivity_CloseView, self.OnCloseActivitySelf) self:RefreshTaskInfoPanel() end function UIGoldenHeroStoryTaskInfo:OnCloseActivitySelf(viewClassPath, activityId) if viewClassPath == self.__viewClassPath then if self.activityId and activityId == self.activityId then self:CloseView() end end end function UIGoldenHeroStoryTaskInfo:OnButtonClicked(comp) if comp == self.btn_Close then self:CloseView() EventSystem.Dispatch(EventID.UI_GoldenHeroStory_RecoverPathPosition) elseif comp == self.btn_GoTo then -- 前往任务 if not MDL.Team.IsFollowing() then CTL.GoldenHeroStory.ShowSkipTaskPopUp(self.activityId, self.heroType, function() self:DoTask() self:CloseView(true) end) else CTL.Tips.AddTipsMsg(Const_IDS.IDS_Team_FollowCanNotDoThis) end end end function UIGoldenHeroStoryTaskInfo:DoTask() if self.taskServerData then CTL.Task.DoTask(self.taskServerData) UIManager.RecoverTopView() CTL.HomeMain.CloseOpenView() end end function UIGoldenHeroStoryTaskInfo:OnBackButtonPressed() self:OnButtonClicked(self.btn_Close) end function UIGoldenHeroStoryTaskInfo:OnCellInit(scrollRect, index, cellTable, data) if scrollRect == self.scroll_RewardPanel then UTL.Item.SetItemCell(cellTable.item, data.ItemID, data.ItemNum) end end function UIGoldenHeroStoryTaskInfo:OnCellClicked(scrollRect, index, cellTable, target, data) if scrollRect == self.scroll_RewardPanel then UTL.ItemTips.ShowCommonTipsById(data.ItemID) end end function UIGoldenHeroStoryTaskInfo:RefreshTaskInfoPanel() local taskList = MDL.Task.GetTaskList(MDL.Task.Enum_TaskType.GoldHeroActivity) if taskList then for __, task in pairs(taskList) do if self.storyTaskCfg.TaskChainID == task.taskChildData[1].TaskLineID then self.taskServerData = task end end end local taskData = DataSheetManager.TaskFatherData:GetDataByID(self.storyTaskCfg.TaskChainID) UIUtils.SetLabelText(self.txt_Task, Const_IDS[taskData.Brief]) -- 任务目标 UIUtils.SetLabelText(self.txt_Desc, Const_IDS[taskData.Desc]) -- 任务描述 UIUtils.SetActive(self.group_Reward,false) if self.state == MDL.GoldenHeroStory.Enum_TaskState.Doing and self.storyTaskCfg.RewardClientShowID > 0 and (self.taskServerData and self.taskServerData.taskInfo.childInfo[1].taskChildId <= self.storyTaskCfg.CompleteChildTaskID) then local cfg = DataSheetManager.RewardClientShow:GetDataByClientShowID(self.storyTaskCfg.RewardClientShowID) local rewardData = DataSheetUtil.GetRewardClientShowItemTable(cfg) if rewardData and #rewardData > 0 then UIUtils.SetActive(self.group_Reward,true) self.scroll_RewardPanel:ClearCells() for i, reward in ipairs(rewardData) do self.scroll_RewardPanel:AddData(reward,0) end end end UIUtils.SetActive(self.btn_GoTo.gameObject, self.state == MDL.GoldenHeroStory.Enum_TaskState.Doing) -- 分支选择提示显隐 UIUtils.SetActive(self.lab_Notice.gameObject, false) for k,groupData in DataSheetManager.GoldHeroActivityGroup[self.heroType]:GetEnumerator() do for i,taskID in ipairs(groupData.TaskID) do if taskID == self.storyTaskCfg.TaskID and #groupData.NextGroupID > 1 then UIUtils.SetLabelText(self.lab_Notice, Const_IDS.IDS_GoldHeroActivity_ActivityLevel_BranchHint1) UIUtils.SetActive(self.lab_Notice.gameObject, true) end end end end return UIGoldenHeroStoryTaskInfo